
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it = (c).begin(); it != (c).end(); ++it)

const int limit = 50050;

void prime_list(vector<unsigned int> &plist, unsigned int max_prime){

    if(plist.size() && plist[plist.size()-1] >= max_prime ) return;
    if(max_prime <= 2){
        plist.push_back(2);
        return;
    }

    unsigned int rt = int(sqrt((double)max_prime));
    prime_list(plist, rt);

    unsigned int bias = plist[plist.size()-1] + 1;
    if(bias == 3) bias = 2;
    unsigned int num = (max_prime - bias + 1) / 2;
    if(num == 0) return;

    char *l = new char[num];
    memset(l, 1, num);

    FOREACH(it, plist){
        unsigned int prime = *it;
        if(prime > rt) break;
        unsigned int st = max(rt - (rt % prime), prime);
        for(unsigned int i = st; i <= max_prime; i += prime){
            if(i >= bias){
                unsigned int idx = i - bias;
                if(idx % 2 == 1){
                    l[idx/2] = 0;
                }
            }
        }
    }
    for(unsigned int i = 0; i < num; i++){
        if(l[i]){
            plist.push_back(bias + 1 + i * 2);
        }
    }
    delete l;
    return;
}

int main(){
    vector<unsigned int> q;
    prime_list(q, limit);

    unsigned int n;
    while(std::cin >> n){
        int l = 0, r = q.size()-1, c = -1;
        while(l <= r){
            c = (l + r)/2;
            if(q[c] < n){ l = c + 1; continue; }
            if(q[c] > n){ r = c - 1; continue; }
            break;
        }
        if(l > r) c = r;
        if(q[c] == n){
            cout << q[c-1] << " " << q[c+1] << endl;
        } else {
            cout << q[c] << " " << q[c+1] << endl;
        }
    }
}