#include <iostream>
using namespace std;
bool prime[60001];

int main(void) {
  for (int i = 0; i <= 60000; i++) {
    prime[i] = true;
  }
  prime[0] = prime[1] = false;

  for (int i = 2; i <= 60000; i++) {
    if (prime[i]) {
      for (int j = 2; i * j <= 60000; j++) {
	prime[i*j] = false;
      }
    }
  }

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