#include <iostream>
using namespace std;

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