module AOJ_Volume0044;

import std.stdio,std.string,std.conv;


int prime[1000000];

int main()
{
	prime[0] = prime[1] = 0;

	foreach(i;2..1000000)
	{
		prime[i] = 1;
	}
	foreach(i;2..1000000)
	{
		if(prime[i])
		{
			for(int j = i*2; j < 1000000 ;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	string s;
	while((s = readln.chomp).length != 0)
	{
		int n = s.to!int;
		for(int i= n-1;i > 0;i--)
		{
			if(prime[i] == 1) 
			{
				write(i," ");
				break;
			}
		}
		for(int i = n+1; i < 1000000;i++)
		{
			if(prime[i] == 1) 
			{
				i.writeln;
				break;
			}
		}
	}
	return 0;
}