Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)


Fixed submission:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools,copy
cost = 0
N,M,X = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(N)]
combi = itertools.permutations(range(N),N)
sumx = [0]*M
sumfx = [0]*M
for j in range(N):
    for i in range(M):
        sumx[i]+=ca[j][i+1]
        if sumx[i]>=X:
            sumfx[i]=1
    cost += ca[j][0]
ans = cost
if sum(sumfx) != M:
    print(-1)
    
else:
    for a in combi:
        x = copy.copy(sumx)
        fx = copy.copy(sumfx)
        c = cost
        for i in range(len(a)):
            for j in range(1,M+1):
                x[j-1] -= ca[a[i]][j]
                if x[j-1]<X:
                    fx[j-1] = 0

            if sum(fx)!=M:
                break
            else:
                c -= ca[a[i]][0]
                ans = min(c,ans)

    print(ans)

Fixed submission:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
cost = 10**12
N,M,X = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(N)]
combi = itertools.permutations(range(N),N)
for a in combi:
    x = [0]*M
    fx = [0]*M
    c = 0
    for i in range(len(a)):
        for j in range(1,M+1):
            x[j-1] += ca[a[i]][j]
            if x[j-1]>=X:
                fx[j-1] = 1
        c += ca[a[i]][0]
        if c>cost:
            break
        if sum(fx)==M:
            break
    if sum(fx) == M:
        cost = min(c,cost)
print(cost if cost !=10**12 else -1)

Fixed submission:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)

Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np

N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
combi = itertools.permutations(range(N),N)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for a in combi:
        x = sum(ca)[1:]
        fx = np.array([0]*M)
        c = sumcos
        for i in range(len(a)):
            x -= ca[a[i]][1:]
            c -= ca[a[i]][0]
            if sum(x>=X)<M:
                break
            else:
                cost = min(c,cost)
    print(cost)


Fixed submission:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np

N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
combi = itertools.permutations(range(N),N)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for a in combi:
        x = sum(ca)[1:]
        fx = np.array([0]*M)
        c = sumcos
        for i in range(len(a)):
            x -= ca[a[i]][1:]
            c -= ca[a[i]][0]
            if sum(x>=X)<M:
                break
            else:
                cost = min(c,cost)
    print(cost)


Fixed submission:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np
cost = 10**12
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
combi = itertools.permutations(range(N),N)
for a in combi:
    x = np.array([0]*M)
    fx = np.array([0]*M)
    c = 0
    for i in range(len(a)):
        x += ca[a[i]][1:]
        c += ca[a[i]][0]
        if c>cost:
            break
        if sum(x>=X)==M:
            break
    if sum(x>=X)==M:
        cost = min(c,cost)
print(cost if cost !=10**12 else -1)


Fixed submission:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
cost = 10**12
N,M,X = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(N)]
combi = itertools.permutations(range(N),N)
for a in combi:
    x = [0]*M
    fx = [0]*M
    c = 0
    for i in range(len(a)):
        for j in range(1,M+1):
            x[j-1] += ca[a[i]][j]
            if x[j-1]>=X:
                fx[j-1] = 1
        c += ca[a[i]][0]
        if c>cost:
            break
        if sum(fx)==M:
            break
    if sum(fx) == M:
        cost = min(c,cost)
print(cost if cost !=10**12 else -1)

Fixed submission:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)