#C2722. First Repeating Integer

    ID: 46070 Type: Default 1000ms 256MiB

First Repeating Integer

First Repeating Integer

You are given a list of integers and your task is to determine the first integer that appears more than once. In other words, for an array \( A = [a_1, a_2, \dots, a_n] \), find the first element \( a_i \) (with \( i \geq 1 \)) such that there exists some \( j < i \) with \( a_j = a_i \). If no such element exists, output \( -1 \).

This problem tests your ability to process sequences and efficiently identify duplicates.

inputFormat

The first line of the input contains a single integer \(T\), the number of test cases. Each test case consists of two lines:

  • The first line contains an integer \(N\), the number of elements in the list.
  • The second line contains \(N\) space-separated integers representing the list.

outputFormat

For each test case, output a single line containing the first repeating integer in that list. If no repeating integer exists, output \( -1 \).

## sample
1
5
1 2 3 2 5
2

</p>