#include <iostream>
#include <vector>
using namespace std;
#define MAX 100000
int main( void )
{
	vector <bool> primes( MAX+1, false );
	for ( int i = 3; i <= MAX; i += 2 )
		primes[i] = true;

	for ( int i = 3; i <= MAX; i+=2 )
	{
		if ( primes[i] )
		{
			for ( int j = i + i; j <= MAX; j += i )
			{
				primes[j] = false;
			}
		}
	}

	int n;
	while ( cin >> n )
	{
		int max = 0, min = 0;
		int p = n + 2;
		while( !min )
		{
			if ( primes[p] )
				min = p;
			else
				p += 2;
		}

		p = n%2?n:n-1;
		p -= n%2?0:2;
		while( !max )
		{
			if ( primes[p] )
				max = p;
			else
				p -= 2;
		}

		cout << max << " " << min << endl;
	}

}