#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

bool is_prime(int p) {
    for (int i=2; i*i<=p; i++) {
        if (p % i == 0) return false;
    }
    return true;
}

int main() {
    int N;
    while (cin >> N) {
        for (int p1=N-1; ; p1--) {
            if (is_prime(p1)) break;
        }
        for (int p2=N+1; ; p2++) {
            if (is_prime(p2)) break;
        }
        cout << p1 << " " << p2 << endl;
    }
    return 0;
}