#K80812. Find Four Integers with Equal Pair Sum

    ID: 35614 Type: Default 1000ms 256MiB

Find Four Integers with Equal Pair Sum

Find Four Integers with Equal Pair Sum

You are given a non-negative integer \(x\). Your task is to find four integers \(a, b, c, d\) such that \(0 \leq a, b, c, d \leq x\) and the equation \(a+b=c+d\) holds.

If \(x = 0\), the only valid answer is 0 0 0 0. If \(x \ge 4\), one valid solution is to choose \(a=1\), \(b=x-1\), \(c=2\), and \(d=x-2\). For values of \(x\) where no valid integers can be found, output -1.

Note: Print the result for each test case on a new line, with the four numbers separated by a single space, or -1 if no valid solution exists.

inputFormat

The input is read from standard input (stdin). The first line contains an integer \(n\) representing the number of test cases. This is followed by \(n\) lines, each containing a single non-negative integer \(x\).

For example:

5
0
4
10
3
100

outputFormat

For each test case, output a single line. If a valid solution exists, print four integers \(a\), \(b\), \(c\), and \(d\) separated by spaces such that \(a+b=c+d\). If no such solution exists, print -1.

For example, the output for the sample input above would be:

0 0 0 0
1 3 2 2
1 9 2 8
-1
1 99 2 98
## sample
5
0
4
10
3
100
0 0 0 0

1 3 2 2 1 9 2 8 -1 1 99 2 98

</p>