CCCGuide

Problem S2: Pretty Average Primes

2019 · S2 · Original problem · DMOJ

Problem Description

For various given positive integers N>3N > 3, find two primes, AA and BB such that NN is the average (mean) of AA and BB. That is, NN should be equal to (A+B)/2(A+B)/2.

Recall that a prime number is an integer P>1P > 1 which is only divisible by 1 and PP. For example, 2, 3, 5, 7, 112,\ 3,\ 5,\ 7,\ 11 are the first few primes, and 4,6,8,94, 6, 8, 9 are not prime numbers.

Input Specification

The first line of input is the number TT (1≤T≤1000)(1 \le T \le 1000), which is the number of test cases. Each of the next TT lines contain one integer NiN_i (4≤Ni≤1 000 000,1≤i≤T)(4 \le N_i \le 1\ 000\ 000, 1 \le i \le T).

For 6 of the available 15 marks, all Ni<1 000N_i < 1\ 000.

Output Specification

The output will consist of TT lines. The iith line of output will contain two integers, AiA_i and BiB_i, separated by one space. It should be the case that Ni=(Ai+Bi)/2N_i = (A_i+B_i)/2 and that AiA_i and BiB_i are prime numbers.

If there are more than one possible AiA_i and BiB_i for a particular NiN_i, output any such pair. The order of the pair AiA_i and BiB_i does not matter.

It will be the case that there will always be at least one set of values AiA_i and BiB_i for any given NiN_i.

Sample Input

4
8
4
7
21

Possible Output for Sample Input

3 13
5 3
7 7
13 29

Explanation of Possible Output for Sample Input

Notice that: 8=(3+13)/2,4=(5+3)/2,7=(7+7)/2,21=(13+29)/2.\begin{align*} 8 & = (3+13)/2, \\ 4 & = (5+3)/2, \\ 7 & = (7+7)/2, \\ 21 & = (13+29)/2. \end{align*} It is interesting to note, that we can also write 8=(5+11)/221=(5+37)/2=(11+31)/2=(19+23)/27=(3+11)/2\begin{align*} 8 & = (5+11)/2 \\ 21 & = (5+37)/2 = (11+31)/2=(19+23)/2 \\ 7 & = (3+11)/2 \\\end{align*} and so any of these pairs could have also been used in output. There is no pairs of primes other than 33 and 55 which average to the value of 44.

Footnote

You may have heard about Goldbach’s conjecture, which states that every even integer greater than 2 can be expressed as the sum of two prime numbers. There is no known proof, yet, so if you want to be famous, prove that conjecture (after you finish the CCC).

This problem can be used to help verify that conjecture, since every even integer can be written as 2N2N, and your task is to find two primes AA and BB such that 2N=A+B2N = A+B.