#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    
    vector<int> vec;
    bool sosu[50050]={false};
    
    vec.push_back(2);
    for(int i=3;i<50050;i+=2){
        if(sosu[i]) continue;
        vec.push_back(i);
        for(int j=i+i;j<50050;j+=i){
            sosu[j] = true;
        }
    }
   
    int n;
    while(cin >> n){
        cout << *(lower_bound(vec.begin(),vec.end(),n)-1) << " " << *upper_bound(vec.begin(),vec.end(),n) << endl;
    }
   
    return(0);
}
