#include <bits/stdc++.h>
using namespace std;

int n, m, k;

bool prime(int a) {
    if (a > 2 && a % 2 == 0)
        return false;

    for (int i = 3; i * i <= a; i += 2)
        if (a % i == 0)
            return false;

    return true;
}

int main()
{
    while (cin >> n) {
        m = n - 1;
        k = n + 1;

        while (!prime(m))
            m--;

        while (!prime(k))
            k++;

        cout << m << " " << k << endl;
    }
}

