#include <iostream>
using namespace std;

int main() {

  const int size = 50022;
  int seq[size] = {};

  for (int i = 2; i < size; ++i)
    for (int j = i * 2; j < size; j += i)
      seq[j] = 1;

  int n;
  while (cin >> n) {
    int v1, v2;

    for (int i = n-1; 0 < i; --i) {
      if (seq[i] == 0) {
        v1 = i;
        break;
      }
    }

    for (int i = n+1; 0 < size; ++i) {
      if (seq[i] == 0) {
        v2 = i;
        break;
      }
    }

    cout << v1 << " " << v2 << endl;
  }

  return EXIT_SUCCESS;
}
