#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;


vector<int> prime;


void sieve(){
	prime.resize(100000);
	iota(prime.begin(), prime.end(), 2);
	for (int i = 0;prime[i]*prime[i] <= 100000;i++){
		prime.erase(remove_if(prime.begin() + (i + 1), prime.end(), [=](int v){ return (v%prime[i] == 0); }), prime.end());
	}
}


int main(){
	int n;
	sieve();
	while (cin >> n){
		cout << *(upper_bound(prime.begin(), prime.end(), n) - 2) << ' ' << *(upper_bound(prime.begin(), prime.end(), n)) << endl;
	}

	return 0;
}