#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
	int n;
	while (cin >> n) {
		vector<int> pl(n*n, 0);
		vector<int> res(2);
		pl[2] = 1;
		for (int i=3; i<n*n; i+=2) pl[i] = 1;
		for (int i=3; i<n; i+=2) {
			if (pl[i] == 0) continue;
			for (int j=i*2; j<=n*n; j+=i) pl[j] = 0;
		}
		for (int i=n; i>0; i--) {
			if (pl[i]==1) {
				res[0] = i;
				break;
			}
		}
		for (int i=n; i<n*n; i++) {
			if (pl[i]==1) {
				res[1] = i;
				break;
			}
		}
		cout << res[0] << " " << res[1] << endl;
	}
}