def isprime(n):
if n == 0 or n == 1: return 'false'
for i in range(2, int(n**.5) + 1):
if n%i == 0: return 'false'
return 'true'
def isperm(n1, n2, n3):
n1 = str(n1); n2 = str(n2); n3 = str(n3)
for d in n1:
if (d not in n2) or (d not in n3): return 'false'
for d in n2:
if (d not in n1) or (d not in n3): return 'false'
for d in n3:
if (d not in n1) or (d not in n2): return 'false'
return 'true'
n1 = 1487
answer = 'false'
while n1 < 10000 and answer == 'false':
n1 += 2
if isprime(n1) == 'false': continue
n3 = n2 = n1
step = 0
while n3 < 9999 and answer == 'false':
step += 1
n2 = n1 + step; n3 = n2 + step
if (isprime(n2) == 'true') and (isprime(n3) == 'true') and (isperm(n1, n2, n3) == 'true'):
answerset = [n1, n2, n3]
answer = 'true'
print answerset