# -*- coding:utf-8 -*-
import random
import time
list=[0,1,2,3,4,5,6,7,8,9]
start_time=time.time()
while True:
slice = random.sample(list, 8)
s, e, n, d, m, o, r, y = slice
if s!=0 and m!=0:
if (s*1000+e*100+n*10+d)+(m*1000+o*100+r*10+e)==(m*10000+o*1000+n*100+e*10+y):
print s,e,n,d,m,o,r,y
break
end_time=time.time()
print 'time=%.2fsecs'%(end_time-start_time)