#include<iostream>
#include<math.h>
using namespace std;



bool judgePrimenum(int n){

	int sqr = sqrt((double)n);

	if(n%2 == 0)return false;

	for(int i=3;i<=sqr;i+=2){
		if(n%i == 0)return false;
	}

	return true;
}




int main(){
	int n, min=0, max=0, i=1;
	cin >> n;

	while(min==0 || max==0){
		if( max==0 && judgePrimenum(n+i) )max=n+i;
		if( min==0 && judgePrimenum(n-i) )min=n-i;
		++i;
	}
	
	cout << min << " " << max << endl;

	return 0;
}