#include <iostream>
#include <cmath>
using namespace std;

bool isPrime(int n) {
    if (n <= 2) return true;
    if (n % 2 == 0) return false;
    for (int i=3; i<=sqrt(n); i+=2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int n, sp, lp;
    while (cin >> n) {
        for (int i=n-1; i>=2; --i) {
            if (isPrime(i)) {
                sp = i;
                break;
            }
        }
        for (int i=n+1; i<=50001; ++i) {
            if (isPrime(i)) {
                lp = i;
                break;
            }
        }
        cout << sp << " " << lp << endl;
    }
    return 0;
}