#include<iostream>
#include<list>
#include<set>
#include<cmath>

int main()
{
    //accept input
    std::list<int> inputs;
    int input_max = 5, n;
    while( true ){
        std::cin >> n;
        if( n == 0 ) break;
        if( n > input_max ) input_max = n;
        inputs.push_back(n);
    }

    //find prime numbers( <= input_max )
    std::list<int> primes;
    primes.push_back(3);
    std::list<int>::iterator itr;
    int sqrt_i;
    for( int i = 5; i <= input_max; i += 2 ) {
        sqrt_i = (int)std::sqrt(i);
        for( itr = primes.begin(); itr != primes.end(); itr++ ){
            if( i % *itr == 0 ) break;
            else if( *itr > sqrt_i ){
                primes.push_back(i);
                break;
            }
        }
    }

    //prime numbers -> twin prime set
    std::set<int> twin_prime_st;
    int prev = 2;
    for( itr = primes.begin(); itr != primes.end(); itr++ ){
        if( *itr == prev + 2 ) twin_prime_st.insert(*itr);
        prev = *itr;
    }

    //find each max twin price
    std::set<int>::iterator st_itr;
    for( itr = inputs.begin(); itr != inputs.end(); itr++ ){
        st_itr = twin_prime_st.upper_bound(*itr);
        st_itr--;
        std::cout << *st_itr - 2 << " " << *st_itr << std::endl;
    }

    return 0;

}
