Buggy python submission (verdict: Time Limit Exceeded):
n, m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*(2**n)
dp[0] = 0
for i in range(m):
    a, b = input().split(' ')
    a = int(a)
    b = int(b)
    M = 0
    for j in input().split(' '):
        M += 2**(int(j)-1)

    for j in range(2**n):
        dp[j|M] = min(dp[j]+a, dp[j|M])
        # dp[j|M] = dp[j] + a if dp[j] + a < dp[j|M] else dp[j|M]

print(dp[2**n-1] if dp[2**n-1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))
dp = [float('inf')]*(2**n)
dp[0] = 0
for i in range(m):
    a, b = input().split(' ')
    a = int(a)
    b = int(b)
    M = 0
    for j in input().split(' '):
        M += 2**(int(j)-1)

    for j in range(2**n):
        dp[j|M] = min(dp[j]+a, dp[j|M])

print(dp[2**n-1] if dp[2**n-1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().strip().split())
dp = [float('inf')]*(2**n)
dp[0] = 0
for i in range(m):
    a, b = input().strip().split()
    a = int(a)
    b = int(b)
    M = 0
    for j in input().strip().split():
        M += 2**(int(j)-1)

    for j in range(2**n):
        dp[j|M] = min(dp[j]+a, dp[j|M])

print(dp[2**n-1] if dp[2**n-1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().strip().split())
dp = [float('inf')]*(2**n)
dp[0] = 0
for i in range(m):
    a, b = input().strip().split()
    a = int(a)
    b = int(b)
    M = 0
    for i in input().strip().split():
        M += 2**(int(i)-1)

    for j in range(2**n):
        dp[j|M] = min(dp[j]+a, dp[j|M])

print(dp[2**n-1] if dp[2**n-1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

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

n, m = map(int, input().strip().split())
dp = [float('inf')] * (2**n)
dp[0] = 0
for i in range(m):
    a, b = input().strip().split()
    a = int(a)
    b = int(b)
    c = input().strip().split()
    mask = 0
    for i in c:
        mask += 2**(int(i) - 1)

    for j in range(2**n):
        dp[j | mask] = min(dp[j] + a, dp[j | mask])

print(dp[2**n - 1] if dp[2**n - 1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

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

n, m = map(int, input().strip().split())
dp = [float('inf')] * (2**n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().strip().split())
    c = map(int, input().strip().split())
    mask = 0
    for i in c:
        mask += 2**(i - 1)

    for j in range(2**n):
        dp[j | mask] = min(dp[j] + a, dp[j | mask])

print(dp[2**n - 1] if dp[2**n - 1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

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

n, m = map(int, input().strip().split())
dp = [float('inf')] * (2**n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().strip().split())
    c = list(map(int, input().strip().split()))
    mask = 0
    for i in c:
        mask += 2**(i - 1)

    for j in range(2**n):
        dp[j | mask] = min(dp[j] + a, dp[j | mask])

print(dp[2**n - 1] if dp[2**n - 1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

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

n, m = map(int, input().strip().split())
dp = [float('inf')] * (1 << n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().strip().split())
    c = list(map(int, input().strip().split()))
    mask = 0b0
    for i in c:
        mask |= 0b1 << (i - 1)

    for j in range(1 << n):
        dp[j | mask] = min(dp[j] + a, dp[j | mask])

print(dp[(1 << n) - 1] if dp[(1 << n) - 1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

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

n, m = map(int, input().strip().split())
dp = [float('inf')] * (1 << n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().strip().split())
    c = list(map(int, input().strip().split()))
    mask = 0b0
    for i in c:
        mask |= 0b1 << (i - 1)

    for j in range(1 << n):
        if dp[j] < float('inf'):
            dp[j | mask] = min(dp[j] + a, dp[j | mask])

print(dp[(1 << n) - 1] if dp[(1 << n) - 1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

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

n, m = map(int, input().strip().split())
dp = [float('inf')] * (1 << n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().strip().split())
    c = np.array(list(map(int, input().strip().split()))) - 1
    mask = 0b0
    for i in c:
        mask |= 0b1 << i

    for j in range(1 << n):
        if dp[j] < float('inf'):
            dp[j | mask] = min(dp[j] + a, dp[j | mask])

print(dp[(1 << n) - 1] if dp[(1 << n) - 1] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

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

n, m = map(int, input().strip().split())
dp = [float('inf')] * (1 << n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().strip().split())
    c = np.array(list(map(int, input().strip().split()))) - 1
    mask = 0b0
    for i in c:
        mask |= 0b1 << i

    for j in range(1 << n):
        if dp[j] < float('inf'):
            dp[j | mask] = min(dp[j] + a, dp[j | mask])

print(dp[1 << n] if dp[1 << n] < float('inf') else -1)

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])

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

n, m = map(int, input().strip().split())
full_mask = 0
for i in range(n):
    full_mask |= 0b1 << i

key_costs = []
box = []
for i in range(m):
    a, b = map(int, input().strip().split())
    c = np.array(list(map(int, input().strip().split()))) - 1
    key_costs.append(a)
    box_mask = 0b0
    for i in c:
        box_mask |= 0b1 << i
    box.append(box_mask)

arr = [-2] * (1 << n)
arr[0] = 0
def calc_min_cost(mask, memo):
    if memo[mask] >= -1:
        return memo[mask]
    
    costs = []
    for idx in range(len(key_costs)):
        if mask & box[idx] == 0:
            continue
        submask = mask & ~box[idx]
        c = calc_min_cost(submask, memo)
        if c == -1:
            costs.append(-1)
        else:
            costs.append(key_costs[idx] + c)

    costs = np.array(costs)
    feasible_costs = costs[costs >= 0]
    if feasible_costs.size == 0:
        memo[mask] = -1
    else:
        memo[mask] = min(feasible_costs)
    
    return memo[mask]

print(calc_min_cost(full_mask, arr))

Fixed submission:
n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])