1433_F. Zero Remainder Sum 
You are given a matrix a of size n × m consisting of integers.

You can choose no more than \left⌊m/2\right⌋ elements in each row. Your task is to choose these elements in such a way that their sum is divisible by k 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 k.

Note that you can choose zero elements (and the sum of such set is 0).

Input

The first line of the input contains three integers n, m and k (1 ≤ n, m, k ≤ 70) — the number of rows in the matrix, the number of columns in the matrix and the value of k. The next n lines contain m elements each, where the j-th element of the i-th row is a_{i, j} (1 ≤ a_{i, j} ≤ 70).

Output

Print one integer — the maximum sum divisible by k you can obtain.

Examples

Input


3 4 3
1 2 3 4
5 2 2 2
7 1 1 4


Output


24


Input


5 5 4
1 2 4 2 1
3 5 1 2 4
1 5 7 1 2
3 8 7 1 2
8 4 7 1 6


Output


56

Note

In the first example, the optimal answer is 2 and 4 in the first row, 5 and 2 in the second row and 7 and 4 in the third row. The total sum is 2 + 4 + 5 + 2 + 7 + 4 = 24.
```python
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write('\n'.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7


n,m,k=mdata()
A=[mdata() for i in range(n)]
dp1=[-INF]*k
dp1[0]=0
for i in range(n):
    dp=[[-INF]*(m//2+1) for _ in range(k)]
    dp[0][0]=0
    for j in range(m):
        a=A[i][j]
        for x in range(m // 2,0,-1):
            for y in range(k):
                dp[(y+a)%k][x]=max(dp[(y+a)%k][x],dp[y][x-1]+a)
    dp2=dp1[::]
    for x in range(k):
        for y in range(k):
            dp2[(x+y)%k]=max(dp2[(x+y)%k],dp1[x]+max(dp[y]))
    dp1=dp2[::]
out(dp1[0])
```