n, m, k = map(int, input().split())
prices = []
min_sum = 0

for _ in range(n):
    row = list(map(int, input().split()))
    prices.append(row)
    min_sum += row[0]

if min_sum > k:
    print(-1)
else:
    dp = [False] * (k + 1)
    dp[0] = True  # Initial state before considering any country

    for country in prices:
        new_dp = [False] * (k + 1)
        # Iterate through all possible sums up to k
        for j in range(k + 1):
            if dp[j]:
                for a in country:
                    if j + a <= k:
                        new_dp[j + a] = True
        # Check if there's any valid sum after processing this country
        if not any(new_dp):
            print(-1)
            exit()
        dp = new_dp

    # Find the maximum possible sum that does not exceed k
    max_sum = 0
    for j in range(k, -1, -1):
        if dp[j]:
            max_sum = j
            break
    print(k - max_sum)