#include<iostream>
using namespace std;
int main(){
long i,j,k,n;
while(cin>>n){
if(n/2*2==n)k=1;else k=2;
for(j=n-k;j>=3;j-=2){
for(i=3;i*i<n;i+=2)if(j%i==0)break;
if(i*i>=n){cout<<j;break;}
}
if(j==1)cout<<"2";

for(j=n+k;;j+=2){
for(i=3;i*i<n;i+=2)if(j%i==0)break;
if(i*i>=n){cout<<" "<<j<<endl;break;}
}

}
return 0;
}