#include<cstdio>
#include<iostream>
#include<cmath>

#define NMAX 50000+100
#define YES 0
#define NO 1

using namespace std;

int main(void){

	int hurui[NMAX]={YES};

	hurui[0]=NO,hurui[1]=NO;
	for(int i=2;i<sqrt((double)NMAX);i++){
		if(hurui[i]==YES){
			for(int j=i+i;j<NMAX;j+=i){
				hurui[j]=NO;
			}
		}
	}

	int inp;

	while(cin>>inp){
		for(int i=inp-1;;i--){
			if(hurui[i]==YES){
				cout<<i<<" ";
				break;
			}
		}
		for(int i=inp+1;;i++){
			if(hurui[i]==YES){
				cout<<i<<endl;
				break;
			}
		}
	}

	return 0;
}