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,…,sr form one team in exactly two situations: r=1 and s1 picked s1, or s1 picked s2, s2 picked s3, ..., sr−1 picked sr, and sr picked s1.
For example, suppose a class has 7 students numbered 1 through 7 and the picks came out like this.
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|
| 3 | 1 | 3 | 7 | 3 | 4 | 6 |
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.
The first line contains the number of test cases T. The first line of each test case contains the number of students n (2≤n≤100,000). The second line lists the number that each student picked, in order from student 1 to student n. Students are numbered 1 through n.
For each test case, print on one line the number of students who ended up on no project team.