import numpy as np N, M, K = map(int, input().split()) dp = np.zeros(K + 1, dtype=bool) dp[K] = True for _ in range(N): A = map(int, input().split()) new_dp = np.zeros(K + 1, dtype=bool) for a in A: new_dp[:-a] |= dp[a:] dp = new_dp if not np.any(dp): print(-1) exit() print(dp.nonzero()[0][0])