#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

bool f[60000];

int main(){
	for(int i=0; i<60000; ++i){
		f[i] = true;
	}
	for(int i=2; i*i<60000; ++i){
		if(f[i]){
			for(int j=2; j*i<60000; ++j){
				f[i*j]=false;
			}
		}
	}
	int n;
	while(cin >> n){
		int over,under;
		for(int i=n-1; i>=2; --i){
			if(f[i]){
				under=i;
				break;
			}
		}
		for(int i=n+1; i<60000; ++i){
			if(f[i]){
				over=i;
				break;
			}
		}
		cout << under << " " << over << "\n";
	}
	return 0;
}