import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.range;

void main(){

    int[] primes = [2,3,5];
    for(int i=7;i<60000;i++){
	bool flg = true;
	for(int j=0;primes[j]*primes[j]<=i;j++){
	    if(i % primes[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg) primes ~= i;
    }
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	int n = to!int(chomp(s));
	auto a = assumeSorted(primes);
	auto p = a.lowerBound(n);
	if(primes[p.length-1] == n) writef("%d %d\n",primes[p.length-1],primes[p.length+1]);
	else{
	    auto p1 = a.upperBound(n);
	    writef("%d %d\n",primes[p.length-1],p1[0]);
	}
    }
}