#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


bool prime[50050];
vector <int> pri;

int main(){
	memset(prime,0,sizeof(prime));
	rep(i,50050){
		prime[i]=true;
	}
	prime[1]=false;
	prime[0]=false;
	for(int i=1;i*i<50050;i++){
		if(prime[i]){
			//cout<<i<<" ";
			for(int j=i*i;j<50050;j+=i){
				prime[j]=false;
			}
		}
	}
	rep(i,50050){
		if(prime[i]) pri.push_back(i);
	}
	int n;
	while(cin>>n){
		int smo,lar;
		rep(i,pri.size()){
			if(pri[i]<n){
			}
			else{
				if(prime[n]==true){
					smo=pri[i-1];
					lar=pri[i+1];
				}
				else{
					smo=pri[i-1];
					lar=pri[i];
				}
				break;
			}
		}
		cout<<smo<<" "<<lar<<endl;
	}
	
	return 0;
}
		