#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000

using namespace std;

int prime[MAX];

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

	REP(i,2,50001)
	{
		prime[i] = 1;
	}

	REP(i,2,50001)
	{
		if(prime[i])
		{
			for(int j = 2;(j*i) <  50001;j++)
			{
				prime[j*i] = 0;
			}
		}
	}

	int n;

	while(cin >> n)
	{
		int under_max = 0,upper_min = 50001;
		rep(i,n)
		{
			if(prime[i] == 1)
			{
				under_max = max(under_max,i);
			}
		}
		REP(i,n+2,50001)
		{
			if(prime[i] == 1)
			{
				upper_min = min(upper_min,i);	
			}
		}

		cout << under_max << " " << upper_min << endl;
	}


	return 0;
}