#include <iostream>
using namespace std;

bool prime(int n) {
	switch (n) {
	case 1: return false;
	case 2:
	case 3: return false;
	}
	if (n % 2 == 0 || n % 3 == 0) return false;
	if (n % 6 != 1 && n % 6 != 5) return false;
	for (int j = 5; j * j <= n; j += 6) {
		if (n % j == 0) return false;
		if (n % (j + 2) == 0) return false;
	}
	return true;
}
int main() {
	int n;
	while (cin >> n) {
		int sn = 0;
		int bn = 0;
		for (int i = 1;; i++) {
			if (sn == 0 && prime(n - i)) sn = n - i;
			if (bn == 0 && prime(n + i)) bn = n + i;
			if (sn != 0 && bn != 0) break;
		}
		cout << sn << " " << bn << endl;
	}
	return 0;
}
