#include <bits/stdc++.h>
using namespace std;

vector<int> sieveOfEratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i) primes[i] = i;
  for (int i = 2; i * i < n; ++i) {
    if (primes[i]) {
      for (int j = i * i; j < n; j += i) primes[j] = 0;
    }
  }
  // primes.erase(remove(begin(primes), end(primes), 0), end(primes));
  return primes;
}

int main() {
  int n;
  auto v = sieveOfEratosthenes(51001);
  while (cin >> n) {
    for (int i = n - 1; i >= 0; --i) {
      if (v[i]) {
        cout << v[i] << ' ';
        break;
      }
    }
    for (int i = n + 1; i <= 51000; ++i) {
      if (v[i]) {
        cout << v[i] << endl;
        break;
      }
    }
  }
  return 0;
}

