#C3207. First Unique Integer Finder

    ID: 46609 Type: Default 1000ms 256MiB

First Unique Integer Finder

First Unique Integer Finder

Given (T) test cases, each consisting of a list of integers, your task is to find the first integer that occurs exactly once in the list. If no such integer exists, output (-1).

For example, for the input list [4, 5, 1, 2, 5, 1, 4, 3], the answer is 2 because the integer 2 appears only once and all previous numbers occur more than once.

Please note: Your solution must read from standard input (stdin) and print the result to standard output (stdout).

inputFormat

The first line contains an integer (T), the number of test cases. Each test case consists of two lines. The first line contains an integer (N) denoting the number of elements in the array. The second line contains (N) space-separated integers.

outputFormat

For each test case, print the first unique integer on a new line. If there is no unique integer in the given test case, print (-1).## sample

4
8 4 5 1 2 5 1 4 3
8 1 2 2 1 3 4 3 3
9 7 7 7 6 6 6 5 5 5
1 9
2

4 -1 9

</p>