#include<iostream>
using namespace std;

int smallprime(int x)
{
	for(int i=x; i<2; i--)
	{
		if((i%2==0) ||(i%3==0) || (i%4==0)||(i%5==0)||(i%6==0) || (i%7==0) || (i%8==0) || (i%9==0))
			continue;
		else
		{
			if((i/1==i) && (i/i==1))
				return i;
			break;
		}
	}
}
	int bigprime(int x)
	{
		for(int i=x; ; i++)
		{
			if((i%2==0) ||(i%3==0) || (i%4==0)||(i%5==0)||(i%6==0) || (i%7==0) || (i%8==0) || (i%9==0))
			continue;
		else
		{
			if((i/1==i) && (i/i==1))
				return i;
			break;
		}
		}
	}
	int main()
	{
		int x;
		while(cin>>x)
		{
			if((x<3) || (x>50000))
				break;
			else
			{
				cout<<smallprime(x)<<" "<<bigprime(x)<<endl;
			}
		}
		return 0;
	}