import math

t = 1000000
a = 0

def isPrime(n):
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

while True:
    t += 1
    if isPrime(t) and isPrime(sum([int(x) for x in str(t)])):
        a += 1;
        print t
        if a == 2: break
