n, m, k = map(int, input().split()) dp = [[False] * (k + 1) for _ in range(n + 1)] dp[0][k] = True for i in range(1, n + 1): A = list(map(int, input().split())) for a in A: for j in range(k - a + 1): if dp[i - 1][j + a]: dp[i][j] = True for j in range(k + 1): if dp[-1][j]: print(j) break else: print(-1)