#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**8)

INF = float("inf")





def bit(n, k):

    return (n >> k) & 1





def main():

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

    C = [0]*N

    A = [None]*N

    for i in range(N):

        C[i], *A[i] = list(map(int, input().split()))



    min_money = INF

    # 全探索

    for i in range(1 << N):

        tot = [0]*M

        money = 0

        for n in range(N):

            if bit(i, n):

                money += C[n]

                for j in range(M):

                    tot[j] += A[n][j]



        if all(tot[j] >= X for j in range(M)):

            min_money = min(money, min_money)

    if min_money == INF:

        print((-1))

    else:

        print(min_money)



    return





if __name__ == '__main__':

    main()

#!/usr/bin/env python3

import sys

import itertools

sys.setrecursionlimit(10**8)

INF = float("inf")





def bit(n, k):

    return (n >> k) & 1





def main():

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

    C = [0]*N

    A = [None]*N

    for i in range(N):

        C[i], *A[i] = list(map(int, input().split()))



    min_money = INF

    # 全探索

    for pattern in itertools.product((0, 1), repeat=N):

        # for i in range(1 << N):

        tot = [0]*M

        money = 0

        for i, use in enumerate(pattern):

            if use == 0:

                continue

            money += C[i]

            for j in range(M):

                tot[j] += A[i][j]



        if all(tot[j] >= X for j in range(M)):

            min_money = min(money, min_money)

    if min_money == INF:

        print((-1))

    else:

        print(min_money)



    return





if __name__ == '__main__':

    main()

#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10**8)
INF = float("inf")


def bit(n, k):
    return (n >> k) & 1


def main():
    N, M, X = list(map(int, input().split()))
    C = [0] * N
    A = [None] * N
    for i in range(N):
        C[i], *A[i] = list(map(int, input().split()))
    min_money = INF
    # 全探索
    for i in range(1 << N):
        tot = [0] * M
        money = 0
        for n in range(N):
            if bit(i, n):
                money += C[n]
                for j in range(M):
                    tot[j] += A[n][j]
        if all(tot[j] >= X for j in range(M)):
            min_money = min(money, min_money)
    if min_money == INF:
        print((-1))
    else:
        print(min_money)
    return


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys
import itertools

sys.setrecursionlimit(10**8)
INF = float("inf")


def bit(n, k):
    return (n >> k) & 1


def main():
    N, M, X = list(map(int, input().split()))
    C = [0] * N
    A = [None] * N
    for i in range(N):
        C[i], *A[i] = list(map(int, input().split()))
    min_money = INF
    # 全探索
    for pattern in itertools.product((0, 1), repeat=N):
        # for i in range(1 << N):
        tot = [0] * M
        money = 0
        for i, use in enumerate(pattern):
            if use == 0:
                continue
            money += C[i]
            for j in range(M):
                tot[j] += A[i][j]
        if all(tot[j] >= X for j in range(M)):
            min_money = min(money, min_money)
    if min_money == INF:
        print((-1))
    else:
        print(min_money)
    return


if __name__ == "__main__":
    main()

+import itertools -    for i in range(1 << N): +    for pattern in itertools.product((0, 1), repeat=N): +        # for i in range(1 << N): -        for n in range(N): -            if bit(i, n): -                money += C[n] -                for j in range(M): -                    tot[j] += A[n][j] +        for i, use in enumerate(pattern): +            if use == 0: +                continue +            money += C[i] +            for j in range(M): +                tot[j] += A[i][j]