#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 100010;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    vector<int> prime(MAX_N, 1);
    prime[0] = prime[1] = 0;
    for(int i = 2; i * i < MAX_N; i++)
    {
        for(int j = 2 * i; j < MAX_N; j += i)
        {
            prime[j] = 0;
        }
    }
    while(cin >> n)
    {
        for(int i = n - 1; ; i--)
        {
            if(prime[i] == 0) continue;
            cout << i << " ";
            break;
        }
        for(int i = n + 1; ; i++)
        {
            if(prime[i] == 0) continue;
            cout << i << endl;
            break;
        }
    }
    return 0;
}


