f=[]
sum=0
def check():
global f
ma=[0,2,3,5,7,11,13,17]
for i in range(1,8):
s=''
s+=str(f[i])
s+=str(f[i+1])
s+=str(f[i+2])
x=int(s)
if x % ma[i]!=0:
return False
return True
def oput():
global f
s=''
for i in f:
s+=str(i)
return int(s)
def go(k):
global f
global sum
for i in range(10):
if i not in f:
f.append(i)
if len(f)==10:
if check()==True:
tp=oput()
print(tp)
sum+=tp
go(k+1)
f.pop()
go(1)
print(sum)