#include <iostream>
using namespace std;
int main(){
  int prime[55002];
  prime[0] = prime[1] = 0;
  for(int i = 2 ; i < 55001 ; i++)prime[i] = 1;

  for(int i = 2 ; i*i < 55001 ; i++){
    if(prime[i] == 1 ){
      for(int j = i*2 ; j < 55001 ; j+=i)prime[j] = 0;
    }
  }

  int n;
  while(cin >> n){
    int ans_M,ans_m;

    for(int i = n-1 ;; i-- ){
      if(prime[i]){
	ans_m = i;break;
      }
    }
    for(int i = n+1 ;; i++ ){
      if(prime[i]){
	ans_M = i;break;
      }
    }
    cout << ans_m<<" "<<ans_M<<endl;

  }
}