The first line has the number of test cases T (1≤T≤100).
The first line of each test case has the number of players N (1≤N≤10000). Each of the next N lines has one integer, the i-th of them being Ai (1≤Ai≤N), the player that player i points at.
Heehyun is player 1 and Jookyung is player N. When N is 1, Heehyun and Jookyung are the same person.