#K37922. Pair Sum Finder

    ID: 26084 Type: Default 1000ms 256MiB

Pair Sum Finder

Pair Sum Finder

You are given a sequence of integers and a target sum \( k \). Your task is to find a pair of distinct elements \( (a, b) \) in the sequence such that:

[ a + b = k ]

If such a pair exists, output the pair in increasing order (i.e. \( a \leq b \)); if there are multiple valid pairs, output any one of them. If no such pair exists, output -1.

The problem tests your ability to efficiently search for such a pair, typically using hashing techniques or other approaches to reduce time complexity.

inputFormat

The first line of input contains an integer \( T \) representing the number of test cases.

For each test case:

  • The first line contains two integers \( n \) and \( k \) where \( n \) is the number of elements in the sequence and \( k \) is the target sum.
  • The second line contains \( n \) space-separated integers representing the sequence.

Input is given via standard input (stdin).

outputFormat

For each test case, print a single line:

  • If a valid pair exists, output the two integers separated by a space in increasing order.
  • If no such pair exists, output -1.

Output should be to standard output (stdout).

## sample
3
5 9
2 7 11 15 1
4 10
5 6 3 4
3 7
1 2 4
2 7

4 6 -1

</p>