The first line is the number of test cases.
For each test case, the first line consists of three integers $N$, $K$, and $T (N, K \leq 6, T\leq 12)$.
In the next $N$ lines, each line consists of $N$ integers $A_{i, j}$.If $A_{i, j} = -1$, the blank $(i, j)$ must be empty. If $A_{i, j} = 0$, a server is require to put on this blank. Otherwise, a server of type $A_{i, j}$ is on this blank.
In the next $T$ lines, each line consists of $K$ pair of integers. Each pair of integers donate the coordinate of blank in this group.