#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	int hyou[50100] = {1};
	for (int i = 1; i < 50100; i++) {
		if (hyou[i] == 0) {
			for (int j = 2; (i+1) * j < 50100; j++) {
				hyou[(i+1)*j-1] = 1;
			}
		}
	}
	while (cin >> n) {
		for(int i = n-2; i >= 0; i--) {
			if (hyou[i] == 0) {
				cout << i+1 << " ";
				break;
			}
		}
		for (int i = n; i < 50100; i++) {
			if (hyou[i] == 0) {
				cout << i+1 << endl;
				break;
			}
		}
	}
	return 0;

}