move the knight

0

0 votes
Problem

Give the no of next steps the knight can make followed by the next step co ordinates. here the starting box of chess board starts from x=1 and y=1 and last box of the chess board is x=8 and y=8

Sample Input
2
4 4
6 7
Sample Output
8
3 6 5 6 6 5 6 3 5 2 3 2 2 3 2 5
6
8 8 8 6 7 5 5 5 4 6 4 8
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

when knight is in 4 4 position there are 8 possible steps it can do they are {3,6}{5,6}{6,5}{6,3}{5,2}{3,2}{2,3}{2,5} when knight is in 6 7 position there are 6 possible steps it can do they are {8,8}{8,6}{7,5}{5,5}{4,6}{4,8}

Editor Image

?