function main() {
  var
  i, j, flag,
  primes = [2,3,5,7,11,13,17];
  for(i = 19;i < 80000; i += 2) {
    flag = true;
    for(j = 0; primes[j] < i*i; j++) {
      if(i % primes[j] == 0) {
        flag = false;
        break;
      }
    }
    if(flag) {
      primes.push(i);
    }
  }
  input.forEach(function(line) {
    if(line.trim() === '') return;
    var
    i,
    n = parseInt(line, 10);
    for(i = 0; n > primes[i]; i++) ;
    console.log('%d %d', primes[i-1], primes[i] === n ? primes[i+1] : primes[i]);
  });
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});