#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main(){
	//Precalculating Sieve of Eratostenes
	int T;
	cin>>T;
	vector<int> X = vector<int>(T,0);
	int maximum=0;
	for(int i = 0; i < T; i++){
		cin>>X[i];
		if(X[i]>maximum){ maximum = X[i];}
	}
	vector<bool> prime = vector<bool>(maximum,true);
	vector<int> primes = vector<int>();
	int p = 2;
	for(;p * p <= maximum; p++){
		if(prime[p]){
			primes.push_back(p);
			for(int i = p * 2; i<=maximum; i+=p){
				prime[i] =false;
			}
		}
	}
	prime[0] = false;
	prime[1] = false;
	for(p; p<=maximum/2; p++){
		if (prime[p]){
			primes.push_back(p);
		}
	}
	for(int j = 0; j < T; j++){
		int i=0;
		int q = X[j]-primes[i];
		while(not prime[q]){
			i++;
			q = X[j] - primes[i];
		}
		cout<<primes[i]<<" "<<q<<'\n';
	}
	return 0;
}