As you might know, the best way to come up with problems is misreading statements. So here you have one problem created in such a way.
There are $m$ stones and $k$ of their distributions into $n$ boxes. Each distribution of stones can be represented as an array of non-negative integers $a$ such that $a_1 + \dots + a_n = m$. Alice will construct a distribution of stones $b$ for which she will define $\operatorname{cost}(b, a)$ as the minimal number of operations described below needed to make $a$ equal to $b$:
- Take $1$ stone from box $i$ ($1 \le i \le n$) with a positive number of stones and put it in box $j$ ($1 \le j \le n$).
She wants to find the minimal sum of costs for the optimal distribution $b$ to all given distributions.
Input
First line contains $3$ integers $n, m, k$ ($1 \le n, k \le 400, 1 \le m \le 10^9$) — number of boxes, stones, and distributions.
Each of the next $k$ lines contains $n$ non-negative integers $a_{i,j}$ ($a_{i,1} + \dots + a_{i,n} = m$) — description of the distributions.
Output
Output a single integer — answer to the problem.
Examples
Sample Input 1
5 12 3 3 0 4 1 4 5 2 3 1 1 1 2 3 5 1
Sample Output 1
8
Sample Input 2
1 1 2 1 1
Sample Output 2
0
Note
For the first sample case, one possible optimal distribution is $b = \{3, 2, 3, 2, 2\}$. For this distribution $b$ we have:
- For $a = \{3, 0, 4, 1, 4\}$ we have $\operatorname{cost}(b, a) = 3$ since we can apply operations in the following order: $\{3, 0, 4, 1, 4\} \to \{3, 1, 4, 1, 3\} \to \{3, 2, 4, 1, 2\} \to \{3, 2, 3, 2, 2\}$.
- For $a = \{5, 2, 3, 1, 1\}$ we have $\operatorname{cost}(b, a) = 2$ since we can apply operations in the following order: $\{5, 2, 3, 1, 1\} \to \{4, 2, 3, 1, 2\} \to \{3, 2, 3, 2, 2\}$.
- For $a = \{1, 2, 3, 5, 1\}$ we have $\operatorname{cost}(b, a) = 3$ since we can apply operations in the following order: $\{1, 2, 3, 5, 1\} \to \{1, 2, 3, 4, 2\} \to \{2, 2, 3, 3, 2\} \to \{3, 2, 3, 2, 2\}$.
So the sum of costs is $8$. It can be shown that it is not possible to obtain a smaller sum of costs.