#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class PrimeTest{
private:
	std::vector<bool> is_prime_;					//nが素数かどうかをis_prime[n]で判定
	std::vector<unsigned int> prime_numbers_;		//素数の集合

public:
	PrimeTest();

	~PrimeTest();

	const std::vector<unsigned int>& get_prime_numbers() const;

	bool is_prime(unsigned int n);

};
 
PrimeTest::PrimeTest(){
	is_prime_.push_back(false);	//0
	is_prime_.push_back(false);	//1
	is_prime_.push_back(true);	//2
	is_prime_.push_back(true);	//3

	prime_numbers_.push_back(2);
	prime_numbers_.push_back(3);
}
PrimeTest::~PrimeTest(){}

const std::vector<unsigned int>& PrimeTest::get_prime_numbers() const{
	return prime_numbers_;
}

bool PrimeTest::is_prime(unsigned int n){
	if(n >= is_prime_.size()){
		unsigned int i_s = is_prime_.size();
		is_prime_.resize(n + 1, false);

		//i_sからnまでの各数が素数かどうか判定
		for(unsigned int i = i_s; i <= n; i++){
			unsigned int max_val = int(sqrt((double)i));
			bool b = true;
			for(unsigned int j = 0; j < prime_numbers_.size(); j++){
				if(prime_numbers_[j] > max_val){ break;}
				if(i % prime_numbers_[j] == 0){
					b = false;
					break;
				}
			}
			if(b){
				prime_numbers_.push_back(i);
				is_prime_[i] = true;
			}
		}

	}
	return is_prime_[n];
}

int main(int argc, char **argv){
	int n;
	PrimeTest prime_test;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	prime_test.is_prime(50000);

#if INPUT_FROM_FILE
	while(ifs >> n){
#else
	while(std::cin >> n){
#endif
		int sprime = 0;
		int lprime = 0;
	
		for(int i = n - 1; i >= 0; i--){
			if(prime_test.is_prime(i)){
				sprime = i;
				break;
			}
		}
		for(int i = n + 1; ; i++){
			if(prime_test.is_prime(i)){
				lprime = i;
				break;
			}
		}

		std::cout << sprime << " " << lprime << std::endl;
	}
 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}
