import sys

import math



primes = [2]

for line in sys.stdin:

  try:

    n = int(line)

    for i in range(max(primes) + 1, n):

      if i % 2 == 0:

        continue

      elif math.sqrt(i) == 0:

        continue

      elif len([j for j in primes if i % j == 0]) > 0:

        continue

      primes.append(i)

    if n == 3:

      print(2, end=" ")

    else:

      for i in range(n - 1, 1, -1):

        if i % 2 == 0:

          continue

        elif math.sqrt(i) == 0:

          continue

        elif len([j for j in primes if i % j == 0 and i != j]) > 0:

          continue

        print(i, end=" ")

        break

    for i in range(n + 1, n + 1000):

      if i % 2 == 0:

        continue

      elif math.sqrt(i) == 0:

        continue

      elif len([j for j in primes if i % j == 0 and i != j]) > 0:

        continue

      print(i)

      break

  except:

    break

# 04.77 sec -> Time Limit Exceeded?

import sys

import math



# Sieve of Eratosthenes

N = 50021

searchList = list(range(3, N + 1, 2))

primes = [2]

while True:

  top = searchList.pop(0)

  primes.append(top)

  if top > math.sqrt(N):

    break

  searchList = [s for s in searchList if s % top != 0]

primes.extend(searchList)



# solve

for line in sys.stdin:

  try:

    n = int(line)

    pre = 2

    for p in primes:

      if p < n:

        pre = p

      if p > n:

        print((pre, p))

        break

  except:

    break
import sys
import math

primes = [2]
for line in sys.stdin:
    try:
        n = int(line)
        for i in range(max(primes) + 1, n):
            if i % 2 == 0:
                continue
            elif math.sqrt(i) == 0:
                continue
            elif len([j for j in primes if i % j == 0]) > 0:
                continue
            primes.append(i)
        if n == 3:
            print(2, end=" ")
        else:
            for i in range(n - 1, 1, -1):
                if i % 2 == 0:
                    continue
                elif math.sqrt(i) == 0:
                    continue
                elif len([j for j in primes if i % j == 0 and i != j]) > 0:
                    continue
                print(i, end=" ")
                break
        for i in range(n + 1, n + 1000):
            if i % 2 == 0:
                continue
            elif math.sqrt(i) == 0:
                continue
            elif len([j for j in primes if i % j == 0 and i != j]) > 0:
                continue
            print(i)
            break
    except:
        break

# 04.77 sec -> Time Limit Exceeded?
import sys
import math

# Sieve of Eratosthenes
N = 50021
searchList = list(range(3, N + 1, 2))
primes = [2]
while True:
    top = searchList.pop(0)
    primes.append(top)
    if top > math.sqrt(N):
        break
    searchList = [s for s in searchList if s % top != 0]
primes.extend(searchList)
# solve
for line in sys.stdin:
    try:
        n = int(line)
        pre = 2
        for p in primes:
            if p < n:
                pre = p
            if p > n:
                print((pre, p))
                break
    except:
        break

+# 04.77 sec -> Time Limit Exceeded? +# Sieve of Eratosthenes +N = 50021 +searchList = list(range(3, N + 1, 2)) +while True: +    top = searchList.pop(0) +    primes.append(top) +    if top > math.sqrt(N): +        break +    searchList = [s for s in searchList if s % top != 0] +primes.extend(searchList) +# solve -        for i in range(max(primes) + 1, n): -            if i % 2 == 0: -                continue -            elif math.sqrt(i) == 0: -                continue -            elif len([j for j in primes if i % j == 0]) > 0: -                continue -            primes.append(i) -        if n == 3: -            print(2, end=" ") -        else: -            for i in range(n - 1, 1, -1): -                if i % 2 == 0: -                    continue -                elif math.sqrt(i) == 0: -                    continue -                elif len([j for j in primes if i % j == 0 and i != j]) > 0: -                    continue -                print(i, end=" ") +        pre = 2 +        for p in primes: +            if p < n: +                pre = p +            if p > n: +                print((pre, p)) -        for i in range(n + 1, n + 1000): -            if i % 2 == 0: -                continue -            elif math.sqrt(i) == 0: -                continue -            elif len([j for j in primes if i % j == 0 and i != j]) > 0: -                continue -            print(i) -            break