Moving ahead, Gudi now enters a room where the floor is divided into  N x M square tiles, forming a grid with N rows and M columns.
Each square in the grid contains a number of Magical Orbs that Gudi has to absorb if she steps on it. Each Orb increases her Kii power, which is needed to fight the demons. Gudi enters the room on (1, 1) with Zero Kii power and has to makes her way to the exit gate on  (N, M), absorbing the Orbs on the way.  From the current cell, she can move only to the adjacent cell in East, South or South-East direction i.e. from (i, j) to either (i, j+1) , (i+1, j) or (i+1, j+1).
However, her capacity for the Orbs is limited. If she absorbs more than K Orbs, she will explode with the large amount of Kii energy! Help her find a way to absorb as any many Orbs as she can, without exploding.  

Input
The first line contains T. T testcases follow.
First line of each testcase contains 3 space-separated integers, N, M, K. 
Each of the following N  lines contain M space-separated integers, describing the grid.  

Output
Print the maximum number of Orbs that she can absorb without exploding or "-1" (without the quotes) if it can not be done i.e. if there does not exist such a path.  Print the answer to each testcase in a new line.  

Constraints:
 1 ≤ T ≤ 10
 1 ≤ N,M ≤ 100
 1 ≤ K ≤ 500
1 ≤ Values in the Grid ≤ 50

SAMPLE INPUT
2
3 3 7
2 3 1
6 1 9
8 2 3
3 4 9
2 3 4 1
6 5 5 3
5 2 3 4

SAMPLE OUTPUT
6
-1

Explanation

In the first testcase, she can move on squares (1,1) , (2,2) and (3,3) to complete her journey with 6 Orbs.
In the second testcase, every possible path leads to the absorption of more than 9 Orbs.
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T = int(raw_input())
for t in xrange(0, T):
    N, M, K = [int(x) for x in raw_input().split()]
    a = []
    for i in xrange(0, N):
        a.append([int(x) for x in raw_input().split()])
    d = []
    for i in xrange(0, N):
        d.append([])
        for j in xrange(0, M):
            d[i].append(set())

    if a[0][0] <= K:
        d[0][0].add(a[0][0])
    for i in xrange(1, M):
        for k in d[0][i - 1]:
            next_d = k + a[0][i]
            if next_d <= K:
                d[0][i].add(next_d)
    for i in xrange(1, N):
        for k in d[i - 1][0]:
            next_d = k + a[i][0]
            if next_d <= K:
                d[i][0].add(next_d)

    for i in xrange(1, N):
        for j in xrange(1, M):
            for k in d[i - 1][j - 1]:
                next_d = k + a[i][j]
                if next_d <= K:
                    d[i][j].add(next_d)
            for k in d[i][j - 1]:
                next_d = k + a[i][j]
                if next_d <= K:
                    d[i][j].add(next_d)
            for k in d[i - 1][j]:
                next_d = k + a[i][j]
                if next_d <= K:
                    d[i][j].add(next_d)

    if len(d[N - 1][M - 1]) == 0:
        print -1
    else:
        print max(d[N - 1][M - 1])