# EOJ Monthly 2018.10

C. 痛苦的 01 矩阵

$$pain(\boldsymbol M) = \left( \sum_{i=1}^n \sum_{j=1}^n \left( cost(i,j) \right)^2 \right) \bmod (10^9+7)$$

### 样例

Input
3 4 9
1 1
1 2
2 3
3 1
3 3
1 2
1 3
2 2
2 2
2 1
3 1
1 1
2 3

Output
73
48
75
52
29
52
33
52
77
104


### 提示

$$\begin{pmatrix} 1 & 1 & 0 \ 0 & 0 & 1 \ 1 & 0 & 0 \end{pmatrix}$$

$$\begin{pmatrix} 1 & 1 & 0 \ 0 & 0 & 1 \ 1 & 0 & 1 \end{pmatrix}$$

NaN