Group of countries

4

1 votes
Open, Open, Implementation, Recursion, Basic Programming, Arrays, Easy, Mathematics, Open, Basics of Implementation
Problem

People in a group are sitting in a row that is numbered from 1 to N. Every person has been asked the same question that is as follows:

How many people of your country are there in the group?

The answers that are provided may be incorrect. It is known that people of same countries always sit together. If all the given answers are correct, then determine the number of distinct countries that exist. Otherwise, print 'Invalid Data'.

Input format

  • First line: An integer T that denotes the number of test cases
  • For each test case:
    • First line: An integer N that denotes the total number of people who are available in the group
    • Second line: N space-separated integers where Ai denotes the answer that is given by the ith person

Output format

For each test case, print a single line containing a single integer that denotes the distinct countries or 'Invalid Data'.

Constraints

1T1000
1N100
1Ai1000

Sample Input
4
2
1 1
2
1 3
7
1 1 2 2 3 3 3
7
7 7 7 7 7 7 7
Sample Output
2
Invalid Data
4
1
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

First test case, there are two people each from different country.

Second test case, there are only two people but the the second person claims as there are three people of his country.

Contributers:
Editor Image

?