#include<iostream>
#include<cmath>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;

const int M = 50000;
bool prime[M];

void isPrime(){
    fill(prime, prime + M, true);
    prime[0] = prime[1] = false;
  
    for(int i = 2; i < M; i++) {
        if(prime[i])
        for(int j = 2; i*j < M ; j++) {
            prime[i*j] = false;
        }
    }
}
int main(void){
  isPrime();
  int n;
  while(cin>>n){
    long long int i = n - 1;
    while(!prime[i])i--;
    cout<<i<<" ";
    i = n + 1;
    while(!prime[++i]);
    cout<<i<<endl;
  }
  return 0;
}