{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eSoroush and Keshi each have a labeled and rooted tree on $$$n$$$ vertices. Both of their trees are rooted from vertex $$$1$$$.\u003c/p\u003e\u003cp\u003eSoroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to prepare a Codeforces round. To celebrate this fortunate event, they decided to make a memorial graph on $$$n$$$ vertices.\u003c/p\u003e\u003cp\u003eThey add an edge between vertices $$$u$$$ and $$$v$$$ in the memorial graph if \u003cspan class\u003d\"tex-font-style-bf\"\u003eboth\u003c/span\u003e of the following conditions hold: \u003c/p\u003e\u003cul\u003e \u003cli\u003e One of $$$u$$$ or $$$v$$$ is the ancestor of the other in Soroush\u0027s tree. \u003c/li\u003e\u003cli\u003e Neither of $$$u$$$ or $$$v$$$ is the ancestor of the other in Keshi\u0027s tree. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eHere vertex $$$u$$$ is considered ancestor of vertex $$$v$$$, if $$$u$$$ lies on the path from $$$1$$$ (the root) to the $$$v$$$.\u003c/p\u003e\u003cp\u003ePopping out of nowhere, Mashtali tried to find the maximum clique in the memorial graph for no reason. He failed because the graph was too big. \u003c/p\u003e\u003cp\u003eHelp Mashtali by finding the size of the maximum clique in the memorial graph.\u003c/p\u003e\u003cp\u003eAs a reminder, clique is a subset of vertices of the graph, each two of which are connected by an edge.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains an integer $$$t$$$ $$$(1\\le t\\le 3 \\cdot 10^5)$$$ — the number of test cases. The description of the test cases follows.\u003c/p\u003e\u003cp\u003eThe first line of each test case contains an integer $$$n$$$ $$$(2\\le n\\le 3 \\cdot 10^5)$$$.\u003c/p\u003e\u003cp\u003eThe second line of each test case contains $$$n-1$$$ integers $$$a_2, \\ldots, a_n$$$ $$$(1 \\le a_i \u0026lt; i)$$$, $$$a_i$$$ being the parent of the vertex $$$i$$$ in Soroush\u0027s tree.\u003c/p\u003e\u003cp\u003eThe third line of each test case contains $$$n-1$$$ integers $$$b_2, \\ldots, b_n$$$ $$$(1 \\le b_i \u0026lt; i)$$$, $$$b_i$$$ being the parent of the vertex $$$i$$$ in Keshi\u0027s tree.\u003c/p\u003e\u003cp\u003eIt is guaranteed that the given graphs are trees.\u003c/p\u003e\u003cp\u003eIt is guaranteed that the sum of $$$n$$$ over all test cases doesn\u0027t exceed $$$3 \\cdot 10^5$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case print a single integer — the \u003cspan class\u003d\"tex-font-style-bf\"\u003esize\u003c/span\u003e of the maximum clique in the memorial graph.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 1 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n4\n1\n3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first and third test cases, you can pick any vertex.\u003c/p\u003e\u003cp\u003eIn the second test case, one of the maximum cliques is $$$\\{2, 3, 4, 5\\}$$$.\u003c/p\u003e\u003cp\u003eIn the fourth test case, one of the maximum cliques is $$$\\{3, 4, 6\\}$$$.\u003c/p\u003e"}}]}