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

int main() {
    int n;
    vector<int> prime;
    vector<bool> is_prime(100000, true);
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<is_prime.size(); ++i) {
        if(is_prime[i]) {
            prime.push_back(i);
            for(int j=i+i; j<is_prime.size(); j+=i) {
                is_prime[j] = false;
            }
        }
    }
    while(cin >> n) {
        auto it = lower_bound(prime.begin(), prime.end(), n);
        auto it2 = upper_bound(prime.begin(), prime.end(), n);
        cout << *(it-1) << ' ' << *it2 << endl;
    }
}
