N, M, K = map(int, input().split()) DP = [0] * K + [1] for i in range(N): dp = [0] * (K + 1) for a in map(int, input().split()): for i in range(K): if i + a <= K and DP[i + a]: dp[i] = 1 DP = dp try: print(DP.index(1)) except: print(-1)