#include<bits/stdc++.h>
using namespace std;
bool flg[500000]{false};
int main(void){
	int n;
	int i,j;
	
	for(i=2;i*i<=500000;i++){
		if(!flg[i]){
			for(j=2;i*j<=500000;j++){
				flg[i*j]=true;
			}
		}
	}
	//for(i=2;i*i<=500000;i++)	if(!flg[i])	cout<<i<<endl;
	while(1){
		cin>>n;
		if(cin.eof())	break;
		i=n-1;
		while(1){
			if(!flg[i]){
				cout<<i<<" ";
				break;
			}
			i--;
		}
		i=n+1;
		while(1){
			if(!flg[i]){
				cout<<i<<endl;
				break;
			}
			i++;
		}
	}
	return 0;
}
