#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

void tamesiwari(int *table, int n){
	table[1] = 1;
	table[2] = 2;
	int count = 3;
	for(int i = 3; i < n; i += 2){
		bool ok = true;
		for(int j = 3; i >= (j * j); j += 2){
			if(i % j == 0) ok = false;
		}
		if(ok) table[count++] = i;
	}
}

int main(){
	int table[60000] = {0};
	tamesiwari(table, 60000);
	int n = 0;
	while(cin >> n){
		if(cin.eof()) break;
		
		for(int i = 0; i < 60000; i++){
			if(table[i] == n){
				cout << table[i - 1] << " " << table[i + 1] << endl;
				break;
			}
		}
	}

	return 0;
}