#include <cstdio>
#include <cmath>
#include <algorithm>
#define MAX_NUM 100000

using namespace std;

int main(void){
	int n, i, j;
	bool f[MAX_NUM + 1];
	fill(f,f + MAX_NUM + 1,true);
	for(i = 2;i <= sqrt((double)MAX_NUM);i++){
		for(j = i * 2;j <= MAX_NUM;j+=i){
			f[j] = false;
		}
	}
	while(scanf("%d",&n) != EOF){
		for(i = n - 1;!f[i];i--);
		printf("%d ",i);
		for(i = n + 1;!f[i];i++);
		printf("%d\n",i);
	}
	return 0;
}