#include<iostream>

using namespace std;

int main(){
	int prime[50000];
	int ptr=0;
	unsigned long counter = 0;
	prime[ptr++] = 2;
	prime[ptr++] = 3;
	
	for(int no =3 ; no <= 50000 ; no += 2){
		int flag=0;
		for(int i=1 ; prime[i] * prime[i] <= no ; i++){
			counter++;
			if(no % prime[i] == 0){
				flag = 1;
				break; 
			}
		}
		if(!flag)
			prime[ptr++] = no;
	}
	
	int n;
	while(cin>>n){
		int i;
		for(i=0;i<50000;i++){
			if(n<prime[i])break;
		}
		
		if(prime[i-1]==n){
			if(prime[i-2]==n) cout<<prime[i-3];
			else cout<<prime[i-2];
		}
		else cout<<prime[i-1];
		
		cout<<" "<<prime[i]<<endl;
	}
	
}