#include<iostream>
using namespace std;

int main(){
  int n;
  while(cin >> n,n){
    int max=0;
    for(int i=1; i<n; ++i){
      if(i%2==0){break;}
      bool frg = true;
      for(int j=2; j*j<i; ++j){
        if(i%j==0){frg=false; break;}
      }
      if(frg && max<i){max=i;}
    }
    cout << max << " ";
    for(int i=n+1; i<2*n; ++i){
      if(i%2==0){break;}
      bool frg = true;
      for(int j=2; j*j<i; ++j){
        if(i%j==0){frg=false; break;}
      }
      if(frg){cout << i << endl;break;}
    }
  }
  return 0;
}

