#include <iostream>

using namespace std;

int main()
{
    constexpr auto N = 50021, PN = 5134;
    bool checked[N+1] = {};
    int primes[PN] = {};
    for( int i=2, ii=0; i<=N; ++i ) {
        if ( !checked[i] ) {
            primes[ii++] = i;
            for( int j=i; j<N; j+=i ) {
                checked[j] = true;
            }
        }
    }

    int n;
    while( cin >> n ) {
        for( int i=0; i<PN; ++i ) {
            if ( primes[i] >= n ) {
                cout << primes[i-1] << " " << primes[i+(primes[i] == n)] << endl;
                break;
            }
        }
    }
}