class test:
def __init__(self):
a=[0]*8
self.data=[]
self.data1=[]
for c in range(8):
self.data.append(a[:])
self.data1.append(a[:])
for a in range(8):
for b in range(8):
self.data1[a]=self.zou((a,b))
self.step=[]
zoufa=((-2,-1),(-1,-2),(1,-2),(2,-1),(2,1),(1,2),(-1,2),(-2,1))
def zou(self,start):
bb=[]
for c in range(8):
a=start[0]+self.zoufa[c][0]
b=start[1]+self.zoufa[c][1]
if 0<=a<8 and 0<=b<8:
bb.append((a,b))
return bb
def start(self,x,y):
self.step=[]
self.step.append((x,y))
##ii=0
##iii=0
i=0
while 0<=i<63:
try:
x,y=self.step[i]
a,b=self.data1[x][y][self.data[x][y]]
self.data[x][y]+=1
if self.data[a]>0:
pass
else:
self.step.append((a,b))
i=i+1
except:
self.step.pop(i)
self.data[x][y]=0
i-=1
##if i>50 and iii==0:
## ii=i
## iii=1
##if i<ii:
## ii=i
## print '%d'%ii
def prt(self):
if self.step:
print ''
for c in range(8):
b=[str(d[0])+str(d[1])+' ' for d in self.step[c*8:c*8+7]]
print ''.join(b)
else:
print 'no path'