Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list += [a]
    c += [sum(1 << j-1 for j in list(map(int,input().split())))]

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for A,C in zip(a_list,c):
        dp[C|i] = min(dp[C|i],dp[i]+A)

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list += [a]
    c += [sum(1 << j-1 for j in list(map(int,input().split())))]

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

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

n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

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

n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

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

n,m = map(int,input().split())
a_list = []
li = [[0 for i in range(n)] for j in range(m)]

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c = list(map(int,input().split()))
    for j in range(b):
        c[j] -= 1
    for k in c:
        li[i][k] = 1

li = np.array(li)
min_coin = 10**10
for i in range(2**m):
    coin = 0
    bool_list = np.array([0]*n)
    for j in range(m):
        if (i >> j)&1:
            for k in li[j]:
                bool_list = li[j] | bool_list
            coin += a_list[j]
    if np.count_nonzero(bool_list) != n:
        continue
    min_coin = min(min_coin,coin)

if min_coin == 10**10:
    print(-1)
else:
    print(min_coin)

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a_list = []
li = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c = list(map(int,input().split()))
    for j in range(b):
        c[j] -= 1
    li.append(c)

min_coin = 10**10

for i in range(2**m):
    bool_list = []
    coin = 0
    for j in range(m):
        if (i >> j)&1:
            for k in li[j]:
                bool_list += li[j]
            coin += a_list[j]
    bool_list = set(bool_list)
    if len(bool_list) != n:
        continue
    min_coin = min(min_coin,coin)

if min_coin == 10**10:
    print(-1)
else:
    print(min_coin)

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a_list = []
li = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c = list(map(int,input().split()))
    for j in range(b):
        c[j] -= 1
    li.append(c)

min_coin = 10**10

for i in range(2**m):
    bool_list = [False]*n
    coin = 0
    for j in range(m):
        if (i >> j)&1:
            for k in li[j]:
                bool_list[k] = True
            coin += a_list[j]
    if False in bool_list:
        continue
    min_coin = min(min_coin,coin)

if min_coin == 10**10:
    print(-1)
else:
    print(min_coin)

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a_list = []
li = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c = list(map(int,input().split()))
    for j in range(b):
        c[j] -= 1
    li.append(c)

min_coin = 10**10

for i in range(2**m):
    bool_list = [False]*n
    coin = 0
    for j in range(m):
        if (i >> j)&1:
            for k in li[j]:
                bool_list[k] = True
            coin += a_list[j]
    if False in bool_list:
        continue
    min_coin = min(min_coin,coin)

if min_coin == 10**10:
    print(-1)
else:
    print(min_coin)

Fixed submission:
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])