INF = 1 << 60 n, m, k = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(n)] dp = [False for _ in range(k + 1)] dp[0] = True for i in range(n): ndp = [False for _ in range(k + 1)] for j in range(k): if not dp[j]: continue for diff in a[i]: if j + diff <= k: ndp[j + diff] = True dp = ndp for j in range(k, -1, -1): if dp[j]: print(k - j) exit() print("-1")