import itertools

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

lst = []



for i in range(n):

    lst.append([int(i) for i in input().split()])



ans_list = []



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

    for j in itertools.combinations(lst, i):

        under_list = [0] * m

        money = 0

        for k in j:

            money += k[0]

            for i in range(m):

                under_list[i] += k[i + 1]

        if all([i >= x for i in under_list]):

            ans_list.append(money)



if not ans_list:

    ans = -1

else:

    ans = min(ans_list)



print(ans)

import sys

input = sys.stdin.readline





def main():

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



    MONEY = []

    UNDERSTAND = []

    for i in range(n):

        lst = [int(i) for i in input().split()]

        MONEY.append(lst[0])

        UNDERSTAND.append(lst[1:])



    ans = -1

    for i in range(1 << n):

        understand = [0] * m

        money = 0

        for j in range(n):

            if (i >> j) & 1 == 0:

                continue

            money += MONEY[j]

            for k in range(m):

                understand[k] += UNDERSTAND[j][k]

        if all([i >= x for i in understand]):

            if ans == -1:

                ans = money

            else:

                ans = min(ans, money)

    print(ans)





if __name__ == '__main__':

    main()

import itertools

n, m, x = list(map(int, input().split()))
lst = []
for i in range(n):
    lst.append([int(i) for i in input().split()])
ans_list = []
for i in range(1, n + 1):
    for j in itertools.combinations(lst, i):
        under_list = [0] * m
        money = 0
        for k in j:
            money += k[0]
            for i in range(m):
                under_list[i] += k[i + 1]
        if all([i >= x for i in under_list]):
            ans_list.append(money)
if not ans_list:
    ans = -1
else:
    ans = min(ans_list)
print(ans)

import sys

input = sys.stdin.readline


def main():
    n, m, x = list(map(int, input().split()))
    MONEY = []
    UNDERSTAND = []
    for i in range(n):
        lst = [int(i) for i in input().split()]
        MONEY.append(lst[0])
        UNDERSTAND.append(lst[1:])
    ans = -1
    for i in range(1 << n):
        understand = [0] * m
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += MONEY[j]
            for k in range(m):
                understand[k] += UNDERSTAND[j][k]
        if all([i >= x for i in understand]):
            if ans == -1:
                ans = money
            else:
                ans = min(ans, money)
    print(ans)


if __name__ == "__main__":
    main()

-import itertools +import sys -n, m, x = list(map(int, input().split())) -lst = [] -for i in range(n): -    lst.append([int(i) for i in input().split()]) -ans_list = [] -for i in range(1, n + 1): -    for j in itertools.combinations(lst, i): -        under_list = [0] * m +input = sys.stdin.readline + + +def main(): +    n, m, x = list(map(int, input().split())) +    MONEY = [] +    UNDERSTAND = [] +    for i in range(n): +        lst = [int(i) for i in input().split()] +        MONEY.append(lst[0]) +        UNDERSTAND.append(lst[1:]) +    ans = -1 +    for i in range(1 << n): +        understand = [0] * m -        for k in j: -            money += k[0] -            for i in range(m): -                under_list[i] += k[i + 1] -        if all([i >= x for i in under_list]): -            ans_list.append(money) -if not ans_list: -    ans = -1 -else: -    ans = min(ans_list) -print(ans) +        for j in range(n): +            if (i >> j) & 1 == 0: +                continue +            money += MONEY[j] +            for k in range(m): +                understand[k] += UNDERSTAND[j][k] +        if all([i >= x for i in understand]): +            if ans == -1: +                ans = money +            else: +                ans = min(ans, money) +    print(ans) + + +if __name__ == "__main__": +    main()