#include <iostream>
#include <stack>
#include <math.h>
#include <vector>

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);

    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main(){

    int n = 0, tmp = 1, max = 4, qi = 0, qimax = 0;
    std::vector<int> v, Qs;
    while(1){
        std::cin >> tmp;

        if(tmp > max){
            max = tmp;
        }

        if(tmp == 0){
            break;
        }

        v.resize(n+1);
        v[n] = tmp;
        n++;
    }

    for(int i = 3; i <= max; i++){

        if(IsPrime(i) && IsPrime(i+2)){
            Qs.resize(qi + 1);
            //std::cout << i + 2 << std::endl;
            Qs[qi] = (i + 2);
            qi++;
        }

    }
    qi--;
    qimax = qi;
    tmp = 0;
    
    while(tmp < n){

       if( v[tmp] < Qs[qi] ){

            //std::cout << "qi : " << qi << std::endl;    
            qi--;
            continue;

       }else{// v[tmp] >= Qs.top

            v[tmp] = Qs[qi];
            qi = qimax;
            tmp++;

       }

    }
    
    for (int i = 0; i < n; i++){
        std::cout << v[i] - 2 << " " << v[i] << std::endl; 
    }

    
    return 0;
}
