#include <iostream>
#include <cmath>
using namespace std;

bool isprime(int n){
    for (int i = 2; i < sqrt(n); i++)
	if (!(n%i)) return false;
    return true;
}

int main(){
    int bigger, smaller, a;
    while (cin >> a){
	bigger = smaller = a;
	while (1){
	    if (isprime(++bigger)) break;
	}
	while (1){
	    if (isprime(--smaller)) break;
	}
	cout << smaller << " " << bigger << endl;
    }
}