#include <stdio.h>
int IsPrime(int n)
{
	int i;
	if(n<2)return 0;
	if(n==2)return 1;
	if(n%2 == 0)return 0;
	for(i=3; i*i<=n; i++)
		if(n%i == 0)return 0;
	return 1;
}

int main(void)
{
	int n, tmp;
	while(scanf("%d", &n)!=EOF)
	{
		tmp=n-1;
		while(!IsPrime(tmp))tmp--;
		printf("%d ",tmp);
		tmp=n+1;
		while(!IsPrime(tmp))tmp++;
		printf("%d\n", tmp);
	}
	return 0;
}