j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){	if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;}
x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){	if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;}
x=0;} r:; }return 0;}