#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

bool sieve[100010];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    for (int i = 0; i < 100010; ++i)
        sieve[i] = true;

    sieve[0] = sieve[1] = false;

    for (int i = 2; i * i < 100010; ++i)
    {
        if (sieve[i])
        {
            for (int j = 2; i * j < 100010; ++j)
            {
                sieve[i * j] = false;
            }
        }
    }
    int n;
    while (cin >> n)
    {
        for (int i = n - 1; i >= 0; --i)
        {
            if (sieve[i])
            {
                cout << i << " ";
                break;
            }
        }
        for (int i = n + 1; i < 100010; ++i)
        {
            if (sieve[i])
            {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}
