#include <cstdio>
#include <cstring>
using namespace std;

int main() {
  bool p[60001];
  int n, x;

  memset(p, 0, sizeof(bool)*60001);
  for (int i=2; i*i<=60000; i++) {
    if (!p[i]) {
      for (int j=2*i; j<=60000; j+=i) {
        p[j] = true;
      }
    }
  }
  while (scanf("%d", &n) == 1) {
    x = n-1;
    while (p[x]) --x;
    printf("%d ", x);
    x = n+1;
    while (p[x]) ++x;
    printf("%d\n", x);
  }
  return 0;
}