#include<stdio.h>
#define M 10
#define N 6
#define forward1(s,t) if(s && !a[t][k])if(next(k,t))return 1
#define forward2(s,t) if(s && !a[k][s])if(next(s,k))return 1
int a[][M]={
{0,1,1,1,1,1,1,1,1,1},
{0,1,0,0,1,0,0,0,0,1},
{0,0,0,1,1,0,0,1,0,1},
{0,1,1,0,0,0,1,1,0,1},
{0,0,0,0,1,0,0,0,0,1},
{1,1,1,1,1,1,1,1,0,0},
};
int b[2][M*N];
int method=0;
int step=0;
void out(int n)
{
int i;
for(i=0;i<n;) {
printf("(%d,%d)/t",b[1][i],b[0][i]);
if(!(++i%5))
printf("/n");
}
printf("/n");
++method;
}
int next(int x,int y)
{
int k;
a[y][x]=-1;
b[0][step]=x;
if(x==M-1&&y==N-1)
out(step);
forward1((k=x+1)<M,y);
forward2(x,(k=y+1)<N);
forward1((k=x-1)>=0,y);
forward2(x,(k=y-1)>=0);
a[y][x]=0;
--step;
return 0;
}
void main(void)
{
next(0,0);
printf("method=%d/n",method);
}