# Programmer: Sriram Pemmaraju
# Date: Feb 20, 2015
# This program reads a positive integer N and lists all twin
# prime pairs (x, x+2) such that x+2 <= N.

import math

N = int(input("Please type a positive integer: "))

n = 3 # n will take on odd values from 3 through N

# variable to remember if the previously processed number is a prime
previousPrime = False 
while n <= N:
    factor = 2 # initial value of possible factor
    isPrime = True # variable to remember if n is a prime or not
    factorUpperBound = math.sqrt(n) # the largest possible factor we need to test is sqrt(n)

    # loop to generate and test all possible factors
    while (factor <= factorUpperBound):
        # test if n is evenly divisible by factor
        if (n % factor == 0):
            isPrime = False
            break
    
        factor = factor + 1
    
    # Output 
    if isPrime and previousPrime:
        print(n-2, n)
    
    # Update previous prime and move n to the next odd value
    previousPrime = isPrime
    n = n + 2
