import math


def f(x):
    temp = x
    count = 0
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            count += 1
            if i != x // i:
                count += 1
    return temp-count


def difference(x, y):
    return abs(f(x)-f(y))


X = int(input())

temp_dict = {}

start = math.floor(X//2-2*(2*math.sqrt(X)+1))
if start < 1:
    start = 1

for i in range(start, X//2+1):
    if abs(i-(X-i)) <= 2*(2*math.sqrt(X)+1):
        diff = difference(i, X-i)
        if diff not in temp_dict:
            temp_dict[diff] = [[i, X-i]]
        else:
            temp_dict[diff].append([i, X-i])

min_key = min(temp_dict.keys())
for data in temp_dict[min_key]:
    print(data[0], data[1])
for data in temp_dict[min_key][::-1]:
    if data[1] != data[0]:
        print(data[1], data[0])