Buggy python submission (verdict: Time Limit Exceeded):
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
    
import itertools
data = list(range(n))
r = n
cc = list(itertools.permutations(data, r))

count = 0
ans = 10**7
for s in cc:
    count = 0
    sw = [0]*m
    for j in range(len(s)):
        
        for i in range(m):
            sw[i] += a[s[j]][i+1]
        count += a[s[j]][0]
        if count >= ans:
            break
        q = 1
        for k in range(m):
            if sw[k] < x:
                q = 0
                break
        if q == 1:
            ans = min(ans,count)
            break
if ans == 10**7:
    print(-1)
else:
    print(ans)


Fixed submission:
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
ans = 10**7
for i in range(2**n):
    count = 0
    sw = [0]*m
    for j in range(n):
        if (i>>j)&1:
            count += a[j][0]
            for k in range(m):
                sw[k] += a[j][k+1]
    q = 1
    for L in range(m):
        if sw[L] < x:
            q = 0
            break
    if q == 1:
        ans = min(ans,count)
if ans == 10**7:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
    
import itertools
data = list(range(n))
r = n
cc = list(itertools.permutations(data, r))

count = 0
ans = 10**7
for s in cc:
    count = 0
    sw = [0]*n
    for j in range(len(s)):
        
        for i in range(m):
            sw[i] += a[s[j]][i+1]
        count += a[s[j]][0]
        q = 1
        for k in range(m):
            if sw[k] < x:
                q = 0
                break
        if q == 1:
            ans = min(ans,count)
if ans == 10**7:
    print(-1)
else:
    print(ans)


Fixed submission:
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
ans = 10**7
for i in range(2**n):
    count = 0
    sw = [0]*m
    for j in range(n):
        if (i>>j)&1:
            count += a[j][0]
            for k in range(m):
                sw[k] += a[j][k+1]
    q = 1
    for L in range(m):
        if sw[L] < x:
            q = 0
            break
    if q == 1:
        ans = min(ans,count)
if ans == 10**7:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
    
import itertools
data = list(range(n))
r = n
cc = list(itertools.permutations(data, r))

count = 0
ans = 10**7
for s in cc:
    count = 0
    sw = [0]*n
    for j in range(len(s)):
        
        for i in range(m):
            sw[i] += a[s[j]][i+1]
        count += a[s[j]][0]
        q = 1
        for k in range(m):
            if sw[k] < x:
                q = 0
                break
        if q == 1:
            ans = min(ans,count)
if ans == 10**7:
    print(-1)
else:
    print(ans)


Fixed submission:
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
ans = 10**7
for i in range(2**n):
    count = 0
    sw = [0]*m
    for j in range(n):
        if (i>>j)&1:
            count += a[j][0]
            for k in range(m):
                sw[k] += a[j][k+1]
    q = 1
    for L in range(m):
        if sw[L] < x:
            q = 0
            break
    if q == 1:
        ans = min(ans,count)
if ans == 10**7:
    print(-1)
else:
    print(ans)