#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int MAXP = 50004;

bool isP[MAXP];
vector<int> Pv;

int init() {
  fill(isP, isP+MAXP, true);
  isP[0] = isP[1] = false;
  for(int i = 2; i < MAXP; ++i) {
    if(!isP[i]) continue;
    Pv.push_back(i);
    for(int j = i*2; j < MAXP; j += i) isP[j] = false;
  }
  return Pv.size();
}

int main() {
  int n;
  init();
  while(cin >> n) {
    int p = lower_bound(Pv.begin(), Pv.end(), n) - Pv.begin();
    int q = p+1;
    if(Pv[p] == n) --p;
    cout << Pv[p] << " " << Pv[q] << endl;
  }
  return 0;
}