Colorful Board

You are given a board. You are asked to draw M horizontal lines and N vertical lines in that board, so that the whole board is divided into (M +1)×(N +1) cells. So there will be M +1 rows each of which will exactly contain N + 1 cells. Now you are asked to color every cell. For these purpose, you are given four colors. Red Green Blue Orange To make the board more beautiful and colorful, you have to be careful, so that no two adjacent cells contain the same color. Two cells are considered adjacent if they share a common side. You are also given some forbidden cells. You must not draw anything in those cells. But you must color every other cell which are not forbidden using a single color. You have to answer in how many ways you can color this board. Figure: Some examples of valid and invalid coloring, where M = 1, N = 1 and no forbidden cell. Input Input will start with an integer T (T ≤ 50) which indicates the number of test case. Each case will start with two integers M and N (0 ≤ M, N ≤ 6), number of horizontal lines and number of vertical lines. Next line will contain an integer K (0 ≤ K ≤ (M +1)∗(N +1)), which indicates the number of forbidden cells. EachofthenextKlineswillcontaintwointegersxandy(1≤x≤M+1,1≤y≤N+1), representing one forbidden cell, which is y-th cell of x-th row. Each given forbidden cells are distinct. Output For each test case, output a single line in the form ‘Case #: P’, where # will be replaced by the case number and P will be replaced by the number of valid ways you can draw the given board. The result can be very large you should output the result modulo 1000000007. Sample Input 2 11 1 21 00 0

2/2 Sample Output Case 1: 36 Case 2: 4