Time Limit: 500 MS + 1500 MS    Memory Limit: 65536 K 


Description

onmylove has invented a game on n*m grids. There is one positive integer on each grid. Now you can take the numbers from the grids to make your final score as high as possible. The way to get score is like the following: (1) At the beginning, the score is 0; (2) If you take a number which equals to x, the score increase x; (3) If there appears two neighboring empty grids after you taken the number, then the score should be decreased by 2 * ( x & y ) . Here x and y are the values used to existed on these two grids. Please pay attention that "neighboring grids" means there exits and only exits one common border between these two grids. Since onmylove thinks this problem is too easy, he adds one more rule: (4) Before you start the game, you are given some positions and the numbers on these positions must be taken away. Can you help onmylove to calculate: what`s the highest score onmylove can get in the game?

Input

Multiple input cases. For each case, there are three integers n, m, k in a line. n and m describing the size of the grids is n*m. k means there are k positions of which you must take their numbers. The following n lines , each contain m numbers , representing the numbers on the n*m grids. Then k lines follow. Each line contains two integers, representing the row and column of one position and you must take the number on this position. Also, the rows and columns are counted start from 1. limits: 1<= n, m <= 50, , 0 <= k <= n * m, the integer in every gird is not more than 1000.

Output

For each test case, output the highest score on one line.

Sample Input

2 2 1 2 2 2 2 1 1 2 2 1 2 7 4 1 1 1

Sample Output

4 9

Hint

As to the second case in Sample Input, onmylove gan get the highest score when calulating like this: 2 + 7 + 4 - 2 * (2 & 4) - 2 * (2 & 7) = 13 - 2 * 0 - 2 * 2 = 9

Author

onmylove