#include<iostream>
#include<vector>
#define NUM 100000
using namespace std;
int main(){
  int n, prime[NUM], p[NUM],c=0;
  for(int i=0; i<NUM; i++){
   prime[i] = 0;
   p[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[c] = i+1;
      c++;
    }
  }

  while(cin >> n){
    if(n < 3 || n > 50000) continue;
    for(int i=0; i<NUM; i++){
      if(n == p[i]){
      	  c=i;
      	  break;
      }
    }
    if(c-1 < 0 || c+1 > NUM) continue;
    else cout << p[c-1] << " " << p[c+1] << endl;
  }
  return 0;
  
}