#K40357. Sum of Two Primes

    ID: 26624 Type: Default 1000ms 256MiB

Sum of Two Primes

Sum of Two Primes

In this problem, you are given an integer ( N ) for each test case. Your task is to determine whether ( N ) can be expressed as the sum of two prime numbers. If there exists such a pair ( (p, q) ) where both are primes and ( p + q = N ), you should output the first pair found (with ( p ) being the smallest possible prime) in ascending order. If no such pair exists, output -1.

Note: For values of ( N < 4 ) or when no prime pair exists, the output should be -1. Input is provided via standard input (stdin) and results must be output to standard output (stdout).

Mathematically, given an integer ( N ), find primes ( p ) and ( q ) such that:
( p + q = N )
if such a pair exists.

inputFormat

The input begins with an integer ( T ) representing the number of test cases (1 ( \le T \le 10^5 )). Each of the following ( T ) lines contains one integer ( N ) (1 ( \le N \le 10^5 )).

outputFormat

For each test case, output one line. If a valid pair of prime numbers ( (p, q) ) exists such that ( p + q = N ), print ( p ) and ( q ) separated by a space. Otherwise, print -1.## sample

3
10
16
27
3 7

3 13 -1

</p>