#include <iostream>
using namespace std;

bool prime(int n) {
	switch (n) {
	case 1: return false;
	case 2: return true;
	case 3: return true;
	}
	if (n % 2 == 0 || n % 3 == 0) return false;
	if (n % 6 != 1 && n % 6 != 5) return false;
	for (int i = 5; i * i <= n; i += 6) {
		if (n % i == 0) return false;
		if (n % (i + 2) == 0) return false;
	}
	return true;
}

int main() {
	int n;
	while (cin >> n) {
		int sn = 0;
		int bn = 0;
		if (n % 2 == 0) {
			bool check = false;
			for (int i = 1;; i += 2) {
				if (sn == 0 && prime(n - i) == true) sn = n - i;
				if (bn == 0 && prime(n + i) == true) bn = n + i;
				if (sn != 0 && bn != 0) break;
			}
		}
		else {
			for (int i = 2;; i += 2) {
				if (sn == 0 && prime(n - i) == true) sn = n - i;
				if (bn == 0 && prime(n + i) == true) bn = n + i;
				if (sn != 0 && bn != 0) break;
			}
		}
		cout << sn << " " << bn << endl;

	}
	return 0;
}
