9372: CCC '19 S2 - Pretty Average Primes
Description
For various given positive integers N>3, find two primes, A and B such that N is the average (mean) of A and B. That is, N should be equal to $\frac{A+B}{2}$.
Recall that a prime number is an integer P>1 which is only divisible by 1 and P. For example, 2, 3, 5, 7, 11 are the first few primes, and 4, 6, 8, 9 are not prime numbers.
Input
The first line of input is the number $T\ (1≤T≤1000)$, which is the number of test cases.
Each of the next $T$ lines contain one integer $N_i\ (4≤N_i≤1000000,\ 1≤i≤T)$.
For 6 of the available 15 marks, all $N_i<1000$.
Output
The output will consist of $T$ lines. The i-th line of output will contain two integers, $A_i$ and $B_i$, separated by one space. It should be the case that $N_i=\frac{A_i+B_i}{2}$ and that $A_i$ and $B_i$ are prime numbers.
If there are more than one possible $A_i$ and $B_i$ for a particular $N_i$, output any such pair. The order of the pair $A_i$ and $B_i$ does not matter.
It will be the case that there will always be at least one set of values $A_i$ and $B_i$ for any given $N_i$.
Sample 1 Input
4
8
4
7
21
Sample 1 Output
3 13
5 3
7 7
13 29
Notice that:
$8=\frac{3+13}{2}$
$4=\frac{5+3}{2}$
$7=\frac{7+7}{2}$
$21=\frac{13+29}{2}$
It is interesting to note, that we can also write
$8=\frac{5+11}{2}$
$21=\frac{5+37}{2}=\frac{11+31}{2}=\frac{19+23}{2}$
$7=\frac{3+11}{2}$
and so any of these pairs could have also been used in output. There is no pairs of primes other than 3 and 5 which average to the value of 4.