‘Hyper Knights’ is a puzzle game played in a 2D board. Though the game may not be too familiar to you, but in ‘KnightsLand’ it’s a very popular game. The best thing of the game is that many people can play the game together competing others. The rules of the games are as follows: Initially an m × n white board is taken and in each cell an integer is written. After that some cells are colored green and some cells are colored red. All the players are sent one copy of the board. Then each of the players starts placing Hyper Knights (like chess knights) in the board for one hour. No player can see others board. When placing Hyper Knights, each player can use as many Hyper Knights as they want, but the jury accepts a board if the following constraints are fulfilled.
2/3 number of distinct green cells. Each of the next P lines contains two integers i and j, denoting that the cell in ith row and jth column is green. Next line contains an integer Q (Q < m ∗ n) denoting the number of distinct red cells. Each of the next Q lines contains two integers i and j, denoting that the cell in i-th row and j-th column is red. If you place Hyper Knights in all green cells you are guaranteed that no two of them will be in attacking positions. And you may also assume that no cell will be colored both red and green. Output For each case, print a line containing the case number and the maximum score a player can make. After that you have to print the lexicographically smallest Hyper Knight placement that forms the maximum score. Print the row and column position of each Hyper Knight in separate lines. See the samples for details. To check the lexicographical order we first make a list using each Hyper Knight placement as [a1, b1, a2, b2 . . . ax, bx], where cell (ai, bi) contains a Hyper Knight. After that we find the lexicographical order using these lists. For example, [1, 2, 21, 5] is smaller than [1, 11] and [1, 1, 12, 13] is smaller than [1, 1, 12, 13, 1, 3]. Sample Input 2 34 2131 7 2 1 100 1 2 1 100 1 10 4 02 01 21 22 24 2111 1111 0 0 Sample Output Case 1: 110 10 11 12 13 Case 2: 7 00 01 02 03
3/3 11 12