#include<iostream>
#include<cstdio>

int main()
{
	int a[50101]={0};
	int i,j;
	int n,c;

	a[2]=1;
	for(i=3;i<=50100;i+=2){
		if(a[i]==2)
			continue;
		else if(a[i]==0){
			a[i]=1;
			for(j=i*2;j<=50100;j+=i)
				a[j]=2;
		}
	}
	while(scanf("%d",&n)!=EOF){
		for(i=n-1;i>1;i--){
			if(a[i]==1){
				printf("%d ",i);
				break;
			}
		}
		for(i=n+1;i<=50100;i++)
			if(a[i]==1){
				printf("%d\n",i);
				break;
			}
	}
	return 0;
}