#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector<int> sosu(50000, 1);

void eratos() {
  for(int i = 2; i < sqrt(50000); i++) {
    if(sosu[i] == 1) {
      for(int j = 2; i*j < 50000; j++) {
	sosu[i*j] = 0;
      }
    }
  }
}

int main() {
  eratos();

  while(1) {
    int n;
    cin >> n;
  
    for(int i = n-1; i >= 0; i--) {
      if(sosu[i] == 1) {
	cout << i << endl;
	break;
      }
    }
    for(int i = n+1; i < 50000; i++) {
      if(sosu[i] == 1) {
	cout << i << endl;
	break;
      }
    }
  }
  return 0;
}
  

