Problem: You are given a matrix of size consisting of integers.
You can choose no more than elements in each row. Your task is to choose these elements in such a way that their sum is divisible by and this sum is the maximum.
In other words, you can choose no more than a half (rounded down) of elements in each row, you have to find the maximum sum of these elements divisible by .
Note that you can choose zero elements (and the sum of such set is ).
Input Format: The first line of the input contains three integers , and () — the number of rows in the matrix, the number of columns in the matrix and the value of . The next lines contain elements each, where the -th element of the -th row is ().
Output Format: Print one integer — the maximum sum divisible by you can obtain.
Note: In the first example, the optimal answer is and in the first row, and in the second row and and in the third row. The total sum is .