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



C = []

A = []

for _ in range(n):

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

    C.append(tmp[0])

    A.append(tmp[1:])

    

f_inf = float("inf")    

ans = f_inf

for s in range(1<<n):

    cst = 0

    D = [0] * m

    for i in range(n):

        if s>>i & 1:

            cst += C[i]

            for j in range(m):

                D[j] += A[i][j]

    

    flg = True

    for d in D:

        if d < x: flg = False

    if flg: ans = min(ans, cst)



if ans == f_inf: 

  print((-1))

else: 

  print(ans)
def main():

  ## IMPORT MODULE

  #import sys



  #sys.setrecursionlimit(100000)

  #input=lambda :sys.stdin.readline().rstrip()



  f_inf=float("inf")

  #MOD=10**9+7

  

  if 'get_ipython' in globals(): 

    ## SAMPLE INPUT

    n, m, x = 3, 3, 10

    C = [60, 70, 50]

    A = [[2, 2, 4], [8, 7, 9], [2, 3, 9]] 



  else:

    ##INPUT 

    #n = input()

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

    C = []

    A = []

    for _ in range(n):

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

      C.append(tmp[0])

      A.append(tmp[1:])



  ## SUBMITION CODES HERE

  ans = f_inf

  for s in range(1<<n): # 1<<n: 2^n 

    cost = 0

    D = [0] * m

    for i in range(n):

        if s>>i & 1: # Shift s by i times to the right and check if the least significant digit is 1

            cost += C[i]

            for j in range(m):

                D[j] += A[i][j]

    

    flg = True

    for d in D:

        if d < x: flg = False

    if flg: ans = min(ans, cost)



  if ans == f_inf: 

    print((-1))

  else: 

    print(ans)



main()
n, m, x = list(map(int, input().split()))
C = []
A = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])
f_inf = float("inf")
ans = f_inf
for s in range(1 << n):
    cst = 0
    D = [0] * m
    for i in range(n):
        if s >> i & 1:
            cst += C[i]
            for j in range(m):
                D[j] += A[i][j]
    flg = True
    for d in D:
        if d < x:
            flg = False
    if flg:
        ans = min(ans, cst)
if ans == f_inf:
    print((-1))
else:
    print(ans)

def main():
    ## IMPORT MODULE
    # import sys
    # sys.setrecursionlimit(100000)
    # input=lambda :sys.stdin.readline().rstrip()
    f_inf = float("inf")
    # MOD=10**9+7
    if "get_ipython" in globals():
        ## SAMPLE INPUT
        n, m, x = 3, 3, 10
        C = [60, 70, 50]
        A = [[2, 2, 4], [8, 7, 9], [2, 3, 9]]
    else:
        ##INPUT
        # n = input()
        n, m, x = list(map(int, input().split()))
        C = []
        A = []
        for _ in range(n):
            tmp = list(map(int, input().split()))
            C.append(tmp[0])
            A.append(tmp[1:])
    ## SUBMITION CODES HERE
    ans = f_inf
    for s in range(1 << n):  # 1<<n: 2^n
        cost = 0
        D = [0] * m
        for i in range(n):
            if (
                s >> i & 1
            ):  # Shift s by i times to the right and check if the least significant digit is 1
                cost += C[i]
                for j in range(m):
                    D[j] += A[i][j]
        flg = True
        for d in D:
            if d < x:
                flg = False
        if flg:
            ans = min(ans, cost)
    if ans == f_inf:
        print((-1))
    else:
        print(ans)


main()

-n, m, x = list(map(int, input().split())) -C = [] -A = [] -for _ in range(n): -    tmp = list(map(int, input().split())) -    C.append(tmp[0]) -    A.append(tmp[1:]) -f_inf = float("inf") -ans = f_inf -for s in range(1 << n): -    cst = 0 -    D = [0] * m -    for i in range(n): -        if s >> i & 1: -            cst += C[i] -            for j in range(m): -                D[j] += A[i][j] -    flg = True -    for d in D: -        if d < x: -            flg = False -    if flg: -        ans = min(ans, cst) -if ans == f_inf: -    print((-1)) -else: -    print(ans) +def main(): +    ## IMPORT MODULE +    # import sys +    # sys.setrecursionlimit(100000) +    # input=lambda :sys.stdin.readline().rstrip() +    f_inf = float("inf") +    # MOD=10**9+7 +    if "get_ipython" in globals(): +        ## SAMPLE INPUT +        n, m, x = 3, 3, 10 +        C = [60, 70, 50] +        A = [[2, 2, 4], [8, 7, 9], [2, 3, 9]] +    else: +        ##INPUT +        # n = input() +        n, m, x = list(map(int, input().split())) +        C = [] +        A = [] +        for _ in range(n): +            tmp = list(map(int, input().split())) +            C.append(tmp[0]) +            A.append(tmp[1:]) +    ## SUBMITION CODES HERE +    ans = f_inf +    for s in range(1 << n):  # 1<<n: 2^n +        cost = 0 +        D = [0] * m +        for i in range(n): +            if ( +                s >> i & 1 +            ):  # Shift s by i times to the right and check if the least significant digit is 1 +                cost += C[i] +                for j in range(m): +                    D[j] += A[i][j] +        flg = True +        for d in D: +            if d < x: +                flg = False +        if flg: +            ans = min(ans, cost) +    if ans == f_inf: +        print((-1)) +    else: +        print(ans) + + +main()