Go: package main

import (
	"bufio"
	"os"
		"strconv"
	"fmt"
	)

var scanner= bufio.NewScanner(os.Stdin)

func main() {
	MAX := 10001
	SQRT := 100
	isPrime := make([]bool, MAX)
	for i :=range isPrime {
		isPrime[i] = true
	}
	for i := 3; i < SQRT; i += 2 {
		if isPrime[i] {
			for j := i*i; j < MAX; j += i {
				isPrime[j] = false
			}
		}
	}
	// log.Println(isPrime)
	tbl := make([]int, MAX)
	ans := 0
	for i := 5; i < MAX; i += 2 {
		if isPrime[i] && isPrime[i-2] {
			ans = i
		}
		tbl[i] = ans
	}
	// log.Println(tbl)
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		if n&1 == 0 {
			n--
		}
		fmt.Printf("%d %d\n", tbl[n]-2, tbl[n])
	}
}

C++: #include<iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;


bool judge(int n){
	for(int i=2;i*i<=n;i++)
		if(n%i==0)return false;
	return true;
}

int main(){
	int n;
	while(cin >> n, n != 0){
		for(int i=n;i>0;i--){
			if(judge(i)&&judge(i-2)){
				cout<<i-2<<" "<<i<<endl;
				break;
			}
		}
	}
	return 0;
}













/*#include<iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

int so[10010];
int set[10010];//入力

int main(){
	int x=0;
	while(1){
	cin>>set[x];
			if(set[x]==0)break;
		x++;
	}
	
	for(int y=0;y<x;y++){
	
	
	int num[10000];
	for(int i=0;i<set[y];i++){
	num[i]=1;
	}
	
	
	for(int i=2;i<set[y];i++){
		if(num[i]==1){
			for(int j=0;i*(j+2)<set[y];j++){
			num[i*(j+2)]=0;
			}
		}
	}
	for(int i=2;i<set[y];i++){
		if(num[i]){
		so[i]=i;
		}
	}
	
	sort(so, so+set[y],greater<int>() );

	for(int i=0;i<set[y];i++){
		if(so[i]-so[i+1]==2){
		cout<<so[i+1]<<" "<<so[i]<<endl;
			break;
		}
	}
	
	}


}*/
/*
#include<iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

int so[10010];
int set[10010];

int main(){
	
	while(1){
	int n;
		cin>>n;
		if(n==0)break;
		
	
	

	int num[10000];
	for(int i=0;i<n;i++){
	num[i]=1;
	}
	
	
	for(int i=2;i<n;i++){
		if(num[i]==1){
			for(int j=0;i*(j+2)<n;j++){
			num[i*(j+2)]=0;
			}
		}
	}
	for(int i=2;i<n;i++){
		if(num[i]){
		so[i]=i;
		}
	}
	
	sort(so, so+n,greater<int>() );

	for(int i=0;i<n;i++){
		if(so[i]-so[i+1]==2){
		cout<<so[i+1]<<" "<<so[i]<<endl;
			break;
		}
	}
	
}


}*/

C++: // 2011/01/31 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1)
		prime[0] = false;
	if(n>=2)
		prime[1] = false;

	for(int i=2; i<n; i++)
		prime[i] = true;

	for(int i=2; i<n; i++){
		if(!prime[i])
			continue;
		for(int j=i+i; j<n; j+=i)
			prime[j] = false;
		if(n<i*i)
			return;
	}
}

int main()
{
	bool prime[10001];
	eratos(prime, 10001);

	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		for(int i=n; i>=5; i--)
			if(prime[i]&&prime[i-2]){
				cout << i-2 << ' ' << i << endl;
				break;
			}
	}

	return 0;
}

C++: //150
#include <iostream>
#include <cstdio>
using namespace std;

int main(){

	const int x=10001;
	int p[x];
	int i,k,j,n;

	for(i=2; i<x; i++){
		p[i]=1;
	}
	p[0]=p[1]=0;
	for(i=2; i*i<=x; i++){
		if(p[i]){
			for(j=i*2; j<x; j+=i){
				p[j]=0;
			}
		}
	}

	cin >> n;
	
	for(k=n; k>0; k--){
		if(p[k] && p[k-2]){
			cout << k-2 << " " << k << endl;
			break;
		}
	}

}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int main() {
  int i, k, n, j, p1, q1;
  for( i = 2; i <= MAX_V; i++ ) {
    prime[i] = 1;
  }
  for( i = 2; i*i <= MAX_V; i++ ) {
    if (prime[i] ) {
      for( k = 2 * i; k <= MAX_V; k += i ) {
        prime[k] = 0;
      }
    }
  }
  for( ;; ) {
    scanf( "%d", &n );
    if( n == 0 )break;
    for( j = 2; j <= n; j++ ) {
      int isprime = prime[j];
      int isprimee = prime[j-2];
      if( isprime == 1 && isprimee == 1 ) {
        q1 = j;
        p1 = q1 - 2;
      }
    }
    printf( "%d %d\n", p1, q1 );
  }
  return 0;
}

C++: #include <iostream>
using namespace std;

int pri[10000];
bool is_prime[10000];
int prime(int n){
	int p=0;
	for(int i=0;i<n;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<n;i++){
		if(is_prime[i]==true){
			pri[p++] = i;
			for(int j=i+i;j<n;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int main()
{
	int n;
	while(cin >> n){
		if(n==0)
			break;
		int p = prime(n);
		for(int i=p-1;i>=0;i--){
			if(pri[i]+2 == pri[i+1]){
				cout << pri[i] << " " << pri[i+1] << endl;
				break;
			}
		}
	}	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int prime[10001];

void CreatePrime(int n)
{
	rep(i,n)
	{
		prime[i] = 1;
	}

	prime[0] = prime[1] = 0;

	REP(i,2,sqrt(n))
	{
		if(prime[i])
		{
			for(int j=0;i*(j+2) < n;j++)
			{
				prime[i*(j+2)] = 0;
			}
		}
	}
}

int main()
{
	int n;
	CreatePrime(10001);

	while(cin >> n && n)
	{
		for(int i=n;i>=0;i--)
		{
			if(prime[i] && prime[i-2])
			{
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>
const int MAX_V = 10000;
int prime[MAX_V+1];
int hurui(int v){
  int i, k;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  int isprime = prime[v];
  if(isprime) {
    return 1;
  }else{
    return 0;
  }
}

int main() {
  int v;
  while(scanf("%d", &v) != EOF) {
    while(1){
      if(hurui(v) == 0 || hurui(v - 2) == 0){
        v--;
      }else{
        printf("%d %d\n", v - 2, v);
        break;
      }
    }
    if(v == 0){
      break;
    }
  }
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,i;
	while(1){
	scanf("%d",&n);
	if(n==0) break;
		for(i=n;i>0;i--){
			if(i==5||i==7){
				printf("%d %d\n",i,i-2);
				break;
			}
			else if(i%2==0&&i%3==0&&i%5==0&&i%7==0){
				if((i-2)%2==0&&(i-2)%3==0&&(i-2)%5==0&&(i-2)%7==0){
					printf("%d %d\n",i,i-2);
					break;
				}
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>
int isprime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0)return 0;
  }
  return 1;
}
int main(){
  int k,n;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(k=n-2;k>=2;k--){
      if(isprime(k)&&isprime(k+2)){
        printf("%d %d\n",k,k+2);
        break;
      }
    }
  }
  return 0;
}

C++: #include <stdio.h>
int isprime(int n) {
  int i;
  for(i = 2; i * i <= n; i++) {
    if(n % i == 0) return 0;
  }
  return 1;
}

int main(){
  int i, n, max;
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    for(i = n;i > 0;i--){
      if(isprime(i) == 1 && isprime(i - 2) == 1){
        max = i;
        break;
      }
    }
    printf("%d %d\n", max - 2, max);
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
	int k=0;
	vector<int> prid(MAX);
	vector<int> pre(MAX);
	for(int i=0;i<MAX;i++)
		prid[i]=1;
	prid[0]=0;
	prid[1]=0;
	for(int i=0;i*i<MAX;i++)
		if(prid[i]){
			for(int j=i*2;j<MAX;j+=i)
				prid[j]=0;
		}
	for(int i=0;i<MAX;i++)
		if(prid[i])
			pre[k++]=i;
	int n,v;
	while(cin>>n,n){
		k=0;
		while(pre[k++]<n)
		v=k-1;
		for(int j=v;j>=0;j--)
			if(pre[j]-pre[j-1]==2){
				cout<<pre[j-1]<<" "<<pre[j]<<endl;
			break;
			
			
		}
		
	}
	
	return 0;
}