#include <iostream>
#include <cstring>
using namespace std;

bool prime[50001];
int main(){
  memset( prime ,true ,sizeof(prime) );
  prime[0] = prime[1] = false;
  for( int i=2 ; i*i<=50000 ; i++ ){
    if( prime[i] == true ){
      for( int j=i+i ; j<=50000 ; j+=i ){
	prime[j] = false;
      }
    }
  }

  int n;
  while( cin >> n ){
    for( int j=n-1 ; j>=0 ; j-- ){
      if( prime[j] == true ){
	cout << j << " ";
	break;
      }
    }
    for( int j=n+1 ; j<50001 ; j++ ){
      if( prime[j] == true ){
	cout << j << endl;
	break;
      }
    }
  }

  return 0;
}