#Lutece1569. Band Vect0r
Band Vect0r
Migrated from Lutece 1569 Band Vect0r
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Control one's mind but lose heart.
The forth page recorded the skill to withdraw mind-control.
You just need to equivocate to your mind but honest to your heart.
The author of the poetry thought that the heart was composed by vectors in dimensions, and each vector has a weight .
You need to choose some vectors which are linearly independent in to compose a matrix, and the weight of the matrix equals the sum weight of the vectors you chosen.
Now you need to find a matrix with the maximum weight.
Let denotes the component of the vector , vectors are linearly independent in if and only if the equation $\sum_{i = 1}^s k_{i} \times a_{ij} \equiv 0 (\mathrm{mod}~P)$, , can only be satisfied by for .
Input
The first line contains three integers , and .
For the next lines, each line describes a vector.
In the line, there are integers , where is the component of the vector, and is the weight of the vector.
, , , and is a prime.
Output
Print the maximum weight of the matrix.
Samples
3 2 2
0 1 1
1 0 2
1 1 3
5
Resources
The 15th UESTC Programming Contest Final