import numpy as np

from itertools import product





def main():

    N, M, X = list(map(int, input().split()))



    books = np.array([list(map(int, input().split())) for _ in range(N)])



    min_total_cost = 10**9



    for read_flags in product((True, False), repeat=N):

        to_read_books = books[read_flags, :]

        total_cost = to_read_books[:, 0].sum()

        increased_levels = to_read_books[:, 1:].sum(axis=0)



        if min(increased_levels) >= X:

            min_total_cost = min(min_total_cost, total_cost)



    if min_total_cost == 10**9:

        print('-1')

    else:

        print(min_total_cost)





if __name__ == "__main__":

    main()

def main():

    N, M, X = list(map(int, input().split()))



    books = [list(map(int, input().split())) for _ in range(N)]



    min_total_cost = 10**9



    for i in range(2**N):

        total_cost = 0

        learned = [0] * M



        for j in range(N):

            if (i >> j) & 1:

                cost, *points = books[j]

                total_cost += cost



                learned = [x + y for x, y in zip(learned, points)]



        if min(learned) >= X:

            min_total_cost = min(min_total_cost, total_cost)



    if min_total_cost == 10**9:

        print('-1')

    else:

        print(min_total_cost)





if __name__ == "__main__":

    main()

import numpy as np
from itertools import product


def main():
    N, M, X = list(map(int, input().split()))
    books = np.array([list(map(int, input().split())) for _ in range(N)])
    min_total_cost = 10**9
    for read_flags in product((True, False), repeat=N):
        to_read_books = books[read_flags, :]
        total_cost = to_read_books[:, 0].sum()
        increased_levels = to_read_books[:, 1:].sum(axis=0)
        if min(increased_levels) >= X:
            min_total_cost = min(min_total_cost, total_cost)
    if min_total_cost == 10**9:
        print("-1")
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()

def main():
    N, M, X = list(map(int, input().split()))
    books = [list(map(int, input().split())) for _ in range(N)]
    min_total_cost = 10**9
    for i in range(2**N):
        total_cost = 0
        learned = [0] * M
        for j in range(N):
            if (i >> j) & 1:
                cost, *points = books[j]
                total_cost += cost
                learned = [x + y for x, y in zip(learned, points)]
        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)
    if min_total_cost == 10**9:
        print("-1")
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()

-import numpy as np -from itertools import product - - -    books = np.array([list(map(int, input().split())) for _ in range(N)]) +    books = [list(map(int, input().split())) for _ in range(N)] -    for read_flags in product((True, False), repeat=N): -        to_read_books = books[read_flags, :] -        total_cost = to_read_books[:, 0].sum() -        increased_levels = to_read_books[:, 1:].sum(axis=0) -        if min(increased_levels) >= X: +    for i in range(2**N): +        total_cost = 0 +        learned = [0] * M +        for j in range(N): +            if (i >> j) & 1: +                cost, *points = books[j] +                total_cost += cost +                learned = [x + y for x, y in zip(learned, points)] +        if min(learned) >= X: