#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

// 𝑂(𝑁*log(log 𝑁))
vector<int> eratosthenes(int N)
{
    vector<int> res;
    vector<bool> prime(N + 1, 1);
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= N; ++i)
    {
        if (prime[i] == true)
        {
            for (int j = 2 * i; j <= N; j += i)
            {
                prime[j] = false;
            }
        }
    }
    for (int i = 0; i <= N; ++i)
    {
        if (prime[i] == true)
            res.push_back(i);
    }
    sort(res.begin(), res.end());
    return res;
}

int m, M, n;

int main()
{
    auto p = eratosthenes(1000010);
    int l = p.size();
    while (cin >> n)
    {
        for (int i = 0; i + 1 < l && n >= p[i]; i++)
        {
            //cout << p[i] << endl;
            if (n == p[i])
            {
                m = p[i - 1], M = p[i + 1];
                break;
            }
            if (n > p[i] && n < p[i + 1])
            {
                m = p[i], M = p[i + 1];
                break;
            }
        }
        cout << m << " " << M << endl;
    }
}

