There are no more than 100 testcases and there are no more than 3 testcases with n>10^3.
For each testcase, the first line contains a number n (1≤n≤10^5).
Then n−1 lines follow. The ith line contains a single number fi (0≤fi<i), which means that after the ith operation there is a new node numbered i and there is an edge between node i and node fi.