#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;
int main()
{ 
  const int END = -1;
  const int NUM = 50000;
  int num;
  int i,index,index2;
  
  cin >> num;

  vector<int> eratos(NUM);

  for(i = 0;i < NUM - 1 ; i++)
    eratos[i] = i+2;
  eratos[i] = END;
 
  while(!cin.eof()){
    i = 0;
    index2 = 0;
  while(eratos[i]!=END)
    {
      if(eratos[i]!=0)
        {
          index = i + 1;
          while(eratos[index]!=END)
            {    
              if(eratos[index]%eratos[i] == 0)
                {
                  eratos[index] = 0;
                }
              index++;
            }
          
          eratos[index2] = eratos[i];
          
          index2++;
        }

      if(eratos[index2-1] > num)
          break;
      i++;
    }
  if(eratos[index2-2] == num)
    cout << eratos[index2-3] << " " << eratos[index2-1] << endl;
  else
    cout << eratos[index2-2] << " " << eratos[index2-1] << endl;

    cin >> num;

  }
  return 0;
}