#include<iostream>

using namespace std;

const int MAX_NUM =  50000 ;
bool prime_number[MAX_NUM];
 
void prime_create() {
  fill(prime_number, prime_number + MAX_NUM, true);
  prime_number[0] = prime_number[1] = false;
 
  for(int i = 2; i < MAX_NUM; i++) {
    if(prime_number[i])
      for(int j = 2; i*j < MAX_NUM; j++) {
	prime_number[i*j] = false;
      }
  }
}

int main(void){
  prime_create();
  int n;
  while(cin>>n){
    int i;

    for(i = (!prime_number[n]?n:n-1) ; !prime_number[i] ; i --);
    cout<<" "<<i<<" ";
    for(i = (!prime_number[n]?n:n+1) ; !prime_number[i] ; i ++);
    cout<<i<<endl;
  }
}