import sys



def furui(n):

  l = [1 for i in range(n+1)]

  l[0] = 0

  l[1] = 0

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

    if l[i] == 1:

      for j in range(2,n//i+1):

        l[i*j] = 0

  l2 = []

  for i in range (len(l)):

    if l[i] == 1:

      l2.append(i)

  return l2



for line in sys.stdin:

  n = int(line)

  l = furui(n)

  if max(l) == n:

    i1 = l[len(l)-2]

  else:

    i1 = max(l)

  i2 = n

  while True:

    i2 += 1

    flag = 1

    for i in l:

      if i2 % i == 0:

        flag = 0

        break

    if flag:

      break

  print((str(i1) + " " + str(i2)))
MAX = 60000

lst = [i for i in range(MAX)]

lst[0] = lst[1] = 0

for i in range(MAX):

  if lst[i] != 0:

    for j in range(i * 2, MAX, i):

      lst[j] = 0

while 0 == 0:

  try:

    n = int(eval(input()))

    i = n - 1

    j = n + 1

    while lst[i] == 0:

      i -= 1

    while lst[j] == 0:

      j += 1

    print((str(lst[i]) + " " + str(lst[j])))

  except EOFError:

    break

import sys


def furui(n):
    l = [1 for i in range(n + 1)]
    l[0] = 0
    l[1] = 0
    for i in range(2, n + 1):
        if l[i] == 1:
            for j in range(2, n // i + 1):
                l[i * j] = 0
    l2 = []
    for i in range(len(l)):
        if l[i] == 1:
            l2.append(i)
    return l2


for line in sys.stdin:
    n = int(line)
    l = furui(n)
    if max(l) == n:
        i1 = l[len(l) - 2]
    else:
        i1 = max(l)
    i2 = n
    while True:
        i2 += 1
        flag = 1
        for i in l:
            if i2 % i == 0:
                flag = 0
                break
        if flag:
            break
    print((str(i1) + " " + str(i2)))

MAX = 60000
lst = [i for i in range(MAX)]
lst[0] = lst[1] = 0
for i in range(MAX):
    if lst[i] != 0:
        for j in range(i * 2, MAX, i):
            lst[j] = 0
while 0 == 0:
    try:
        n = int(eval(input()))
        i = n - 1
        j = n + 1
        while lst[i] == 0:
            i -= 1
        while lst[j] == 0:
            j += 1
        print((str(lst[i]) + " " + str(lst[j])))
    except EOFError:
        break

-import sys - - -def furui(n): -    l = [1 for i in range(n + 1)] -    l[0] = 0 -    l[1] = 0 -    for i in range(2, n + 1): -        if l[i] == 1: -            for j in range(2, n // i + 1): -                l[i * j] = 0 -    l2 = [] -    for i in range(len(l)): -        if l[i] == 1: -            l2.append(i) -    return l2 - - -for line in sys.stdin: -    n = int(line) -    l = furui(n) -    if max(l) == n: -        i1 = l[len(l) - 2] -    else: -        i1 = max(l) -    i2 = n -    while True: -        i2 += 1 -        flag = 1 -        for i in l: -            if i2 % i == 0: -                flag = 0 -                break -        if flag: -            break -    print((str(i1) + " " + str(i2))) +MAX = 60000 +lst = [i for i in range(MAX)] +lst[0] = lst[1] = 0 +for i in range(MAX): +    if lst[i] != 0: +        for j in range(i * 2, MAX, i): +            lst[j] = 0 +while 0 == 0: +    try: +        n = int(eval(input())) +        i = n - 1 +        j = n + 1 +        while lst[i] == 0: +            i -= 1 +        while lst[j] == 0: +            j += 1 +        print((str(lst[i]) + " " + str(lst[j]))) +    except EOFError: +        break