#include<iostream>
#include<vector>
#define NUM 100000
using namespace std;
int main(){
  int n, prime[NUM],flag;
  vector<int> p;
  for(int i=0; i<NUM; i++) prime[i] = 0;
  prime[0] = 1;
  for(int i=2; i<=NUM/2; i++){
      for(int j=2; i*j <= NUM; j++){
	if(prime[i*j-1] == 0)
	  prime[i*j-1] = 1;
      }
  }
  
  for(int i=0; i<NUM; i++){
    if(prime[i] == 0)
      p.push_back(i+1);
  }

  while(cin >> n){
    flag=0;
    if(n < 3 || n > 50000) return 0;
    vector<int>::iterator it = p.begin();
    while(it != p.end()){
      if(n == *it){
	cout << *(it-1) << " " << *(it+1) << endl;
	flag=1;
      }
      it++;
    }
    if(flag == 0) return 0;
  }
  return 0;
  
}