#include <iostream>
#include <vector>

using namespace std;

int main(){
  const int size=50022;
  bool composite[size]={0};
  composite[0]=composite[1]=true;
  for(int i=0;i<size;i++){
    if(!composite[i]){
      for(int j=i*2;j<size;j+=i){
        composite[j]=true;
      }
    }
  }
  vector<int> array;
  int n;
  while(cin>>n){
    array.push_back(n);
  }

  for(auto number:array){
    int i=0;
    for(i=number-1;composite[i];i--);
    cout<<i<<" ";
    for(i=number+1;composite[i];i++);
    cout<<i<<endl;
  }
}