N,M,K = map(int,input().split()) A = [list(map(int,input().split())) for _ in range(N)] dp = [[0] * 501 for _ in range(N)] for j in range(M): dp[0][A[0][j]] = 1 for i in range(1,N): for j in range(501): if dp[i-1][j]: for k in range(M): dp[i][j+A[i][k]] = 1 flag = False i = K while i > 0 and dp[N-1][i] == 0: i -= 1 if i == 0: print(-1) else: print(K - i)