In a 2^n*2^n chess board, some grids is marked visitable, and others are not. Mr. Ant is planning to visit all the visitable grids on the board, and each grid can be visited only once. Mr. Ant start from the left-top side of the board, and he should finish his journey at any grid on the edge of the board. Of course we assume that the start point of Mr. Ant is always visitable.
In every step, Mr. Ant can move from one grid to the adjacent grid (that is to say he can move up, down, left, right in four directions).
Mr. Ant’s path is defined recursively. That is to say, if Mr. Ant wants to visit a 2^k*2^k chess board, then we divided the board into four pieces, and each one has a size of 2^(k-1)*2^(k-1), in every part, Mr. Ant should visit all the grids in the four parts and then move onto another. Of course, we should divided this 2^(k-1)*2^(k-1) board into four smaller pieces and Mr. Ant’s path should be defined in these new four parts.