
import std.stdio, std.string;

bool[] make_primes(int n) {
  bool primes[] = new bool[](n + 1);
  foreach(ref p; primes) p = true;
  primes[0] = primes[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if (primes[i])
      for(int j = i * 2; j <= n; j += i) {
        primes[j] = false;
    }
  }
  return primes;
}

void main() {
  bool[] primes = make_primes(60000);
  for(int n; readf("%d\n", &n);) {
    int max = n + 1, min = n - 1;
    while(!primes[min]) {min--;}
    while(!primes[max]) {max++;}
    writeln(min, " ", max);
  }
}