#include<stdio.h>
#include<math.h>

int main(){
	int num;
	int ans=0;
	int i,j,k;
	int box[100000];
		
	while(scanf("%d",&num)!=EOF){
		
		for(i=2;i<=80000;i++)box[i]=1;
		
		for(i=2;i<=sqrt(80000);i++){
			if(box[i]==1){
				for(j=2;i*j<=80000;j++){
					box[i*j]=0;
				}
			}
		}
		
		
		for(i=num-1;i>=3;i--)if(box[i]==1){
			printf("%d ",i);
			break;
		}
		for(i=num+1;i<=80000;i++)if(box[i]==1){
			printf("%d\n",i);
			break;
		}
		ans=0;
	}
	return 0;
}