#include <iostream>
using namespace std;
#define MAX 50004

int prime[MAX],judge[MAX]={0};

void p(){
  int num = 0;
  judge[0] = judge[1] = 1;
  for(int i = 2 ; i*i < MAX ; i++){
    if(judge[i] == 0){
      for(int j = i*2 ; j < MAX ; j += i){
        judge[j] = 1;
      }
    }
  }
  
  for(int i = 2 ; i < MAX ; i++){
    if(judge[i] == 0) prime[num++] = i;
  }
}

int main(void){
  int n;

  p();
  while(cin >> n){
    int key = 0;
    while(1){
      if(n == prime[key]){
        cout << prime[key-1] << ' ' << prime[key+1] << endl;
        break;  
      }
      key++;
    }
  }

  return 0;
}