import sys

input = sys.stdin.readline

def main():

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

    ans = 10 ** 9

    C_list = []

    A_list = []

    for _ in range(N):

        CA = list(map(int, input().split()))

        C_list.append(CA[0])

        A_list.append(CA[1:])

    for bit in range(2**N):

        cost = 0

        A = [0 for _ in range(M)]

        clear = True

        for i in range(N):

            if bit & 1<<i:

                cost += C_list[i]

                for j in range(M):

                    A[j] += A_list[i][j]

        for k in range(M):

            clear = clear and (A[k] >= X)

        if clear:

            ans = min(ans, cost)

    if ans == 10 ** 9:

        ans = -1

    print(ans)

if __name__ == "__main__":

    main()
# DFS

import sys

input = sys.stdin.readline

sys.setrecursionlimit(2147483647)

INF = 10 ** 9 + 100

ans = INF

def dfs(i, S, cost, C_list, A_list, N, M, X):

    global ans

    # print(i, buy, cost, S)

    if i == N:

        ok = True

        for j in range(M):

            if S[j] < X:

                ok = False

                break

        if ok:ans = min(ans, cost)

        return

    dfs(i+1, S, cost, C_list, A_list, N, M, X)

    for j in range(M):

        S[j] += A_list[i][j]

    cost += C_list[i]

    dfs(i+1, S, cost, C_list, A_list, N, M, X)

    for j in range(M):

        S[j] -= A_list[i][j]

    cost -= C_list[i]

def main():

    global INF, ans

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

    C_list = []

    A_list = []

    for _ in range(N):

        C_A = list(map(int, input().split()))

        C_list.append(C_A[0])

        A_list.append(C_A[1:])

    S = [0 for _ in range(M)]

    cost = 0

    dfs(0, S, cost, C_list, A_list, N, M, X)

    if ans == INF:ans = -1

    print(ans)

if __name__ == "__main__":

    main()
import sys

input = sys.stdin.readline


def main():
    N, M, X = list(map(int, input().split()))
    ans = 10**9
    C_list = []
    A_list = []
    for _ in range(N):
        CA = list(map(int, input().split()))
        C_list.append(CA[0])
        A_list.append(CA[1:])
    for bit in range(2**N):
        cost = 0
        A = [0 for _ in range(M)]
        clear = True
        for i in range(N):
            if bit & 1 << i:
                cost += C_list[i]
                for j in range(M):
                    A[j] += A_list[i][j]
        for k in range(M):
            clear = clear and (A[k] >= X)
        if clear:
            ans = min(ans, cost)
    if ans == 10**9:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()

# DFS
import sys

input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = 10**9 + 100
ans = INF


def dfs(i, S, cost, C_list, A_list, N, M, X):
    global ans
    # print(i, buy, cost, S)
    if i == N:
        ok = True
        for j in range(M):
            if S[j] < X:
                ok = False
                break
        if ok:
            ans = min(ans, cost)
        return
    dfs(i + 1, S, cost, C_list, A_list, N, M, X)
    for j in range(M):
        S[j] += A_list[i][j]
    cost += C_list[i]
    dfs(i + 1, S, cost, C_list, A_list, N, M, X)
    for j in range(M):
        S[j] -= A_list[i][j]
    cost -= C_list[i]


def main():
    global INF, ans
    N, M, X = list(map(int, input().split()))
    C_list = []
    A_list = []
    for _ in range(N):
        C_A = list(map(int, input().split()))
        C_list.append(C_A[0])
        A_list.append(C_A[1:])
    S = [0 for _ in range(M)]
    cost = 0
    dfs(0, S, cost, C_list, A_list, N, M, X)
    if ans == INF:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()

+# DFS +sys.setrecursionlimit(2147483647) +INF = 10**9 + 100 +ans = INF + + +def dfs(i, S, cost, C_list, A_list, N, M, X): +    global ans +    # print(i, buy, cost, S) +    if i == N: +        ok = True +        for j in range(M): +            if S[j] < X: +                ok = False +                break +        if ok: +            ans = min(ans, cost) +        return +    dfs(i + 1, S, cost, C_list, A_list, N, M, X) +    for j in range(M): +        S[j] += A_list[i][j] +    cost += C_list[i] +    dfs(i + 1, S, cost, C_list, A_list, N, M, X) +    for j in range(M): +        S[j] -= A_list[i][j] +    cost -= C_list[i] +    global INF, ans -    ans = 10**9 -        CA = list(map(int, input().split())) -        C_list.append(CA[0]) -        A_list.append(CA[1:]) -    for bit in range(2**N): -        cost = 0 -        A = [0 for _ in range(M)] -        clear = True -        for i in range(N): -            if bit & 1 << i: -                cost += C_list[i] -                for j in range(M): -                    A[j] += A_list[i][j] -        for k in range(M): -            clear = clear and (A[k] >= X) -        if clear: -            ans = min(ans, cost) -    if ans == 10**9: +        C_A = list(map(int, input().split())) +        C_list.append(C_A[0]) +        A_list.append(C_A[1:]) +    S = [0 for _ in range(M)] +    cost = 0 +    dfs(0, S, cost, C_list, A_list, N, M, X) +    if ans == INF: