#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define SUBIF(a, b, x) ((x) ? (b) : (a))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647LL
#define MOD 1000000007LL
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int n;
bool isPrime[10010];
VI prime;
PII ans[10010];


void makePrime(){
	fill(RNG(isPrime, 10001), true);
	isPrime[0] = isPrime[1] = false;
	for(int i = 2;i*i <= 10000;i++)
		if(isPrime[i])
			for(int j = 2;i*j <= 10000;j++) isPrime[i*j] = false;
	rep(i, 0, 10010)
		if(isPrime[i]) prime.pb(i);
}


void makeAns(){
	ans[5] = { 3, 5 };
	repe(i, 6, 10000){
		if(!isPrime[i]){
			ans[i] = ans[i-1];
			continue;
		}
		int pi = distance(prime.begin(), lower_bound(ALL(prime), i));
		if(prime[pi]-prime[pi-1] == 2) ans[i] = { prime[pi-1], prime[pi] };
		else ans[i] = ans[i-1];
	}
}


int main(){
	makePrime();
	makeAns();
	while(cin >> n, n) cout << ans[n].first << ' ' << ans[n].second << endl;

	return 0;
}
