X = int(input()) L = [1 for k in range(10**6+1)] for k in range(2,10**6+1): l = 1 while k*l < 10**6+1: L[k*l] += 1 l += 1 B = [0 for k in range(X+1)] for k in range(1,X+1): B[k] = k-L[k] t = 10**9 for k in range(1,X+1): t = min(t,abs(B[k]-B[X-k])) ans = [] for k in range(1,X+1): if abs(B[k]-B[X-k]) == t: ans.append([k,X-k]) for e in ans: print(*e)