#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

// 素数判定
template<typename T>
bool is_prime(T n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	T p = (T)sqrt(n);
	for (T i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	vector<int> prime;

	for (int i = 2; i <= 60000; i++)
	{
		if (is_prime(i))
		{
			prime.push_back(i);
		}
	}

	int n;
	for (; cin >> n;)
	{
		int priv, next;
		for (int i = 0; i < prime.size(); i++)
		{
			if (n == prime.at(i))
			{
				priv = prime.at(i - 1);
				next = prime.at(i + 1);
				break;
			}
			else if (n < prime.at(i))
			{
				priv = prime.at(i - 1);
				next = prime.at(i);
				break;
			}
		}

		cout << priv << " " << next << endl;
	}
}

