#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    vector<bool> is_sosu(60000, true);
    is_sosu[0] = false;
    is_sosu[1] = false;
    for(ll i = 2; i <= 55000; i++){
        if(!is_sosu[i]) continue;
        for(ll j = i * 2; j <= 55000; j += i){
            is_sosu[j] = false;
        }
    }
    
    ll n;
    while(scanf("%lld", &n) != EOF){
        for(ll i = n - 1; i >= 0; i--){
            if(is_sosu[i]){
                cout << i << " ";
                break;
            }
        }
        for(ll i = n + 1; i <= 55000; i++){
            if(is_sosu[i]){
                cout << i << endl;
                break;
            }
        }
    }
}
