{"raw_statement":[{"iden":"statement","content":"You are given a tree $T$ with $n$ nodes. The tree is rooted at $1$. Define $\\mathrm{subtree}(u)$ as the set of nodes in the subtree of $u$.\n\nCall a subset of nodes $S$ good if and only if $S$ satisfies at least one of the following contidions:\n\n- For all $u, v\\in S$ where $u\\neq v$, either $u\\in \\mathrm{subtree}(v)$ or $v\\in \\mathrm{subtree}(u)$.\n- For all $u, v\\in S$ where $u\\neq v$, both $u\\notin \\mathrm{subtree}(v)$ and $v\\notin \\mathrm{subtree}(u)$.\n\nYou need to partition all nodes of $T$ into several good subsets. Calculate the minimum number of subsets.\n"},{"iden":"input","content":"The first line contains a single integer $Q$ ($1\\leq Q\\leq 10 ^ 5$), denoting the number of test cases.\n\nFor each test case, the first line contains an integer $n$ ($1\\leq n\\leq 10 ^ 6$). The next line contains $n - 1$ integers $p_2, p_3, \\ldots, p_n$ ($1\\leq p_i < i$), indicating that there is an edge between $p_i$ and $i$ for each $i=2,3,\\ldots,n$.\n\nIt is guaranteed that the sum of $n$ over all test cases is no more than $10 ^ 6$."},{"iden":"output","content":"For each test case, output a single integer representing the answer."},{"iden":"note","content":"**Source**: The 2022 ICPC Asia Xi'an Regional Contest Problem L.\n\n**Author**: Alex_Wei."}],"translated_statement":null,"sample_group":[["2\n7\n1 1 2 2 2 3\n5\n1 2 3 4\n","3\n1\n"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}