Buggy python submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
c_ = [list(map(int,input().split())) for i in range(n)]

cc_ = []
for i in range(n):
    cc_.append(c_[i][0])
# print(cc_)

import numpy as np
import itertools
l_ = np.arange(n).tolist()

res_ = []
resList = []
flag = False
for i in range(2,n+1):
    c = list(itertools.combinations(l_, i))
    for j in c:
        # print(j)
        res_ = []
        flag2 = True
        for l in range(3):
            res = 0
            sum_money = 0
            for k in range(len(j)):
                res += c_[j[k]][l+1]
                sum_money += c_[j[k]][0]
            # print(res,sum_money)
            if res < x:
                flag2 = False
        if flag2:
            resList.append(sum_money)
            flag = True
# print(resList)
print(min(resList) if flag else -1)


Fixed submission:
n,m,x = map(int,input().split())
c_ = [list(map(int,input().split())) for i in range(n)]

# print(c_)
cc_ = []
for i in range(n):
    cc_.append(c_[i][0])
# print(cc_)

import numpy as np
import itertools
l_ = np.arange(n).tolist()

res_ = []
resList = []
flag = False
flag3 = True
if n == 1:
    for i in range(m):
        if c_[0][i+1] < x:
            # print(c_[0][i+1])
            flag3 = False
    print(cc_[0] if flag3 else -1)
else:
    for i in range(1,n+1):
        c = list(itertools.combinations(l_, i))
        for j in c:
            res_ = []
            flag2 = True
            for l in range(m):
                res = 0
                sum_money = 0
                for k in range(len(j)):
                    res += c_[j[k]][l+1]
                    sum_money += c_[j[k]][0]
                # print(res,sum_money)
                if res < x:
                    flag2 = False
            if flag2:
                resList.append(sum_money)
                flag = True
    # print(resList)
    print(min(resList) if flag else -1)

Buggy python submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
c_ = [list(map(int,input().split())) for i in range(n)]

cc_ = []
for i in range(n):
    cc_.append(c_[i][0])
# print(cc_)

import numpy as np
import itertools
l = np.arange(n)

res1_ = []
res2_ = []
res3_ = []
cc_r_ = []
resList = []
flag = False
for i in range(2,n+1):
    c = list(itertools.combinations(l, i))
    for j in c:
        # print(j)
        res1_ = []
        res2_ = []
        res3_ = []
        cc_r_ = []
        for k in range(len(j)):
            res1_.append(c_[j[k]][1])
            res2_.append(c_[j[k]][2])
            res3_.append(c_[j[k]][3])
            cc_r_.append(cc_[j[k]])
        res1 = sum(res1_)
        res2 = sum(res2_)
        res3 = sum(res1_)
        cc_r = sum(cc_r_)
        if res1 >= x and res2 >= x and res3 >= x:
            resList.append(cc_r)
            flag = True

print(min(resList) if flag else -1)


Fixed submission:
n,m,x = map(int,input().split())
c_ = [list(map(int,input().split())) for i in range(n)]

# print(c_)
cc_ = []
for i in range(n):
    cc_.append(c_[i][0])
# print(cc_)

import numpy as np
import itertools
l_ = np.arange(n).tolist()

res_ = []
resList = []
flag = False
flag3 = True
if n == 1:
    for i in range(m):
        if c_[0][i+1] < x:
            # print(c_[0][i+1])
            flag3 = False
    print(cc_[0] if flag3 else -1)
else:
    for i in range(1,n+1):
        c = list(itertools.combinations(l_, i))
        for j in c:
            res_ = []
            flag2 = True
            for l in range(m):
                res = 0
                sum_money = 0
                for k in range(len(j)):
                    res += c_[j[k]][l+1]
                    sum_money += c_[j[k]][0]
                # print(res,sum_money)
                if res < x:
                    flag2 = False
            if flag2:
                resList.append(sum_money)
                flag = True
    # print(resList)
    print(min(resList) if flag else -1)