This list shows the result for a 4×4 table. 0 represents the rook and 1 represents the knight. The second item of (a,b) is the cell position in the table. The first cell is at the 0th position, the last cell is at the 15th. For example, the last output (1,3),(1,7),(0,8),(0,13) tells me the one of the knigts is located at the 3rd cell, which means the first row and the last column, and the other knight is located at the second row and the last column.
What about the algorithm?