

from itertools import combinations

from copy import deepcopy

def main():

    n, m, x = list(map(int, input().split()))

    books = []

    for _ in range(n):

        books.append(list(map(int, input().split())))

    books_pattern = []

    books_num = [i for i in range(n)]

    for i1 in range(1, n + 1):

        books_pattern += list(combinations(books_num, i1))

    skill_set = []



    for ebp in books_pattern:

        skill_pattern = [0] * (m + 1)

        for ebpe in ebp:

            book_e = books[ebpe]

            for i2 in range(m + 1):

                skill_pattern[i2] += book_e[i2]

        skill_set.append(skill_pattern)



    skill_set_ok = []

    for ess in skill_set:

        tess = deepcopy(ess[1:])

        tessc = [i for i in tess if i >= x]

        if len(tessc) == m:

            skill_set_ok.append(ess[0])

    if len(skill_set_ok) > 0:

        print((min(skill_set_ok)))

    else:

        print((-1))











if __name__ == '__main__':

    main()

def main():

    n, m, x = list(map(int, input().split()))

    books = []

    for _ in range(n):

        books.append(tuple(map(int, input().split())))



    books_set_all = []

    for bit in range(1<<n):

        books_set = [0] * (m + 1)

        for i in range(n):

            mask = 1 << i

            if bit & mask:

                for i2 in range(m + 1):

                    books_set[i2] += books[i][i2]

        books_set_all.append(books_set)

    price_all = []

    for ebs in books_set_all:

        price = ebs[0]

        ebs[0] = x

        if len([j for j in ebs if j >= x]) == m + 1:

            price_all.append(price)

    if len(price_all) > 0:

        print((min(price_all)))

    else:

        print((-1))







if __name__ == '__main__':

    main()

from itertools import combinations
from copy import deepcopy


def main():
    n, m, x = list(map(int, input().split()))
    books = []
    for _ in range(n):
        books.append(list(map(int, input().split())))
    books_pattern = []
    books_num = [i for i in range(n)]
    for i1 in range(1, n + 1):
        books_pattern += list(combinations(books_num, i1))
    skill_set = []
    for ebp in books_pattern:
        skill_pattern = [0] * (m + 1)
        for ebpe in ebp:
            book_e = books[ebpe]
            for i2 in range(m + 1):
                skill_pattern[i2] += book_e[i2]
        skill_set.append(skill_pattern)
    skill_set_ok = []
    for ess in skill_set:
        tess = deepcopy(ess[1:])
        tessc = [i for i in tess if i >= x]
        if len(tessc) == m:
            skill_set_ok.append(ess[0])
    if len(skill_set_ok) > 0:
        print((min(skill_set_ok)))
    else:
        print((-1))


if __name__ == "__main__":
    main()

def main():
    n, m, x = list(map(int, input().split()))
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))
    books_set_all = []
    for bit in range(1 << n):
        books_set = [0] * (m + 1)
        for i in range(n):
            mask = 1 << i
            if bit & mask:
                for i2 in range(m + 1):
                    books_set[i2] += books[i][i2]
        books_set_all.append(books_set)
    price_all = []
    for ebs in books_set_all:
        price = ebs[0]
        ebs[0] = x
        if len([j for j in ebs if j >= x]) == m + 1:
            price_all.append(price)
    if len(price_all) > 0:
        print((min(price_all)))
    else:
        print((-1))


if __name__ == "__main__":
    main()

-from itertools import combinations -from copy import deepcopy - - -        books.append(list(map(int, input().split()))) -    books_pattern = [] -    books_num = [i for i in range(n)] -    for i1 in range(1, n + 1): -        books_pattern += list(combinations(books_num, i1)) -    skill_set = [] -    for ebp in books_pattern: -        skill_pattern = [0] * (m + 1) -        for ebpe in ebp: -            book_e = books[ebpe] -            for i2 in range(m + 1): -                skill_pattern[i2] += book_e[i2] -        skill_set.append(skill_pattern) -    skill_set_ok = [] -    for ess in skill_set: -        tess = deepcopy(ess[1:]) -        tessc = [i for i in tess if i >= x] -        if len(tessc) == m: -            skill_set_ok.append(ess[0]) -    if len(skill_set_ok) > 0: -        print((min(skill_set_ok))) +        books.append(tuple(map(int, input().split()))) +    books_set_all = [] +    for bit in range(1 << n): +        books_set = [0] * (m + 1) +        for i in range(n): +            mask = 1 << i +            if bit & mask: +                for i2 in range(m + 1): +                    books_set[i2] += books[i][i2] +        books_set_all.append(books_set) +    price_all = [] +    for ebs in books_set_all: +        price = ebs[0] +        ebs[0] = x +        if len([j for j in ebs if j >= x]) == m + 1: +            price_all.append(price) +    if len(price_all) > 0: +        print((min(price_all)))