Term Project

No attempts yetTime limit3sMemory limit256 MB

Problem

Every student who signed up for the 'Problem Solving' course this fall term has to carry out a term project. There is no limit on how many students a team may have. All of the students can even belong to the same team, leaving a single team. To form the teams, every student picks one student to work with. Only one pick is allowed. A student who wants to work alone may pick themselves.

Students s1,s2,,srs_1, s_2, \ldots, s_r form one team in exactly two situations: r=1r = 1 and s1s_1 picked s1s_1, or s1s_1 picked s2s_2, s2s_2 picked s3s_3, ..., sr1s_{r-1} picked srs_r, and srs_r picked s1s_1.

For example, suppose a class has 7 students numbered 1 through 7 and the picks came out like this.

1234567
3137346

With these picks, (3) and (4, 7, 6) form teams. Students 1, 2, and 5 belong to no team.

Given the result of the picks, write a program that counts the students who belong to no project team.

Input

The first line contains the number of test cases TT. The first line of each test case contains the number of students nn (2n100,0002 \le n \le 100{,}000). The second line lists the number that each student picked, in order from student 11 to student nn. Students are numbered 11 through nn.

Output

For each test case, print on one line the number of students who ended up on no project team.