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

int main() {
	ios_base::sync_with_stdio( false );

	const int N = 50021;
	vector<bool> primes( N+1, true );

	primes[0] = false;
	primes[1] = false;

	for( int i = 2; i*i <= N; ++i ) {
		if( primes[i] ) {
			for( int j = 2*i; j <= N; j += i ) {
				if( j%i == 0 ) {
					primes[j] = false;
				}
			}
		}
	}

	int x;
	while( cin >> x ) {
		int i = x-1;
		int j = x+1;
		while( i >= 0 && !primes[i] ) { i -= 1; }
		while( j <= N && !primes[j] ) { j += 1; }

		cout << i << ' ' << j << '\n';
	}

	return 0;
}

