# Include <stdio. h>
# Include <stdlib. h>
# Define N 8
Int pre [8] [2];
Struct map {int x;
Int y;
Int status;
} Map0 [N] [N];
Struct stack
{Struct map date [40];
Int top;
} St;
Void push (struct stack * M, int xx, int yy)
{
M-> top ++;
M-> date [M-> top]. x = map0 [xx] [yy]. x;
M-> date [M-> top]. y = map0 [xx] [yy]. y;
}
Void pop (struct stack * M)
{
M-> top --;
}
Void print (struct stack * M)
{
Int I = M-> top; int j;
For (j = 1; j <= M-> top; j ++)
Printf ("(% d, % d)->", M-> date [j]. x, M-> date [j]. y );
}
Void try1 (struct stack * M, int xx, int yy)
{Int I; int m; int n;
If (map0 [N-2] [N-2]. status =-1)
{Print (M); return ;}
For (I = 0; I <N; I ++)
{M = xx + pre [I] [0];
N = yy + pre [I] [1];
If (map0 [m] [n]. status = 0)
{Map0 [m] [n]. status =-1;
Push (M, m, n );
Try1 (M, m, n );
Pop (M );
Map0 [m] [n]. status = 0;
}
}
Return;
}
Main ()
{
Int I, j;
Pre [0] [0] = 1; pre [0] [1] = 0;
Pre [1] [1] = 1; pre [1] [0] = 1;
Pre [2] [0] = 0;
Pre [2] [1] = 1; pre [3] [0] =-1;
Pre [3] [1] = 1; pre [4] [0] =-1;
Pre [4] [1] = 0; pre [5] [0] =-1;
Pre [5] [1] =-1; pre [6] [0] = 0; pre [6] [1] =-1;
Pre [7] [0] = 1; pre [7] [1] =-1;
For (I = 0; I <N; I ++)
For (j = 0; j <N; j ++)
{Printf ("map0 [% d] [% d] =", I, j); scanf ("% d", & map0 [I] [j]. status );
Map0 [I] [j]. x = I;
Map0 [I] [j]. y = j ;}
Try1 (& st, 0, 0 );
}