N, M, K = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] dp = [-1] * (K+1) dp[0] = 0 for i in range(N): for j in range(K, -1, -1): if dp[j] == -1: continue for k in range(M): v = j + A[i][k] if v <= K: dp[v] = max(dp[v], dp[j] + 1) for i in range(K, -1, -1): if dp[i] == N: ans = K - i break else: ans = -1 print(ans)