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


n, m = [int(x) for x in input().split()]

costs = []
masks = []

for _ in range(m):
  costs.append(int(input().split()[0]))

  boxes = {int(x)-1 for x in input().split()}
  mask = ['1' if idx in boxes else '0' for idx in range(n)][::-1]
  mask = int(''.join(mask), 2)
  masks.append(mask)

  INF = int(10e8 + 1)
  #dp = np.full(1 << n, INF, dtype=int)
  dp = [INF] * (1 << n)
  dp[0] = 0

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

      res = dp[-1] if dp[-1] != INF else -1
      print(res)

Fixed submission:
n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = [INF] * (1 << n)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    mask = sum(1 << box for box in boxes)
    
    for i in range(1 << n):
        if dp[i] + cost < dp[i | mask]:
            dp[i | mask] = dp[i] + cost

res = dp[-1] if dp[-1] != INF else -1
print(res)

Buggy python submission (verdict: Runtime Error):
    import numpy as np
     
     
    n, m = [int(x) for x in input().split()]
     
    costs = []
    masks = []
     
    for _ in range(m):
        costs.append(int(input().split()[0]))
     
        boxes = {int(x)-1 for x in input().split()}
        mask = ['1' if idx in boxes else '0' for idx in range(n)][::-1]
        mask = int(''.join(mask), 2)
        masks.append(mask)
     
    INF = int(10e8 + 1)
    #dp = np.full(1 << n, INF, dtype=int)
    dp = [INF] * (1 << n)
    dp[0] = 0
     
    for j in range(m):
        for i in range(1 << n):
            dp[i | masks[j]] = min(
                    dp[i | masks[j]],
                    dp[i] + costs[j]
                )
     
    res = dp[-1] if dp[-1] != INF else -1
    print(res)

Fixed submission:
n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = [INF] * (1 << n)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    mask = sum(1 << box for box in boxes)
    
    for i in range(1 << n):
        if dp[i] + cost < dp[i | mask]:
            dp[i | mask] = dp[i] + cost

res = dp[-1] if dp[-1] != INF else -1
print(res)

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


n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = np.full(1 << n, INF, dtype=int)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    mask = sum(1 << box for box in boxes)
    
    for i in range(1 << n):
        if dp[i] + cost < dp[i | mask]:
            dp[i | mask] = dp[i] + cost

res = dp[-1] if dp[-1] != INF else -1
print(res)


Fixed submission:
n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = [INF] * (1 << n)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    mask = sum(1 << box for box in boxes)
    
    for i in range(1 << n):
        if dp[i] + cost < dp[i | mask]:
            dp[i | mask] = dp[i] + cost

res = dp[-1] if dp[-1] != INF else -1
print(res)

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


n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = np.full(1 << n, INF, dtype=int)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    mask = sum(1 << box for box in boxes)
    
    for i in range(1 << n):
        dp[i | mask] = min(
                dp[i | mask],
                dp[i] + cost
            )

res = dp[-1] if dp[-1] != INF else -1
print(res)


Fixed submission:
n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = [INF] * (1 << n)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    mask = sum(1 << box for box in boxes)
    
    for i in range(1 << n):
        if dp[i] + cost < dp[i | mask]:
            dp[i | mask] = dp[i] + cost

res = dp[-1] if dp[-1] != INF else -1
print(res)

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


n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = np.full(1 << n, INF, dtype=int)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    for box in boxes:
        mask |= 1 << box
    
    for i in range(1 << n):
        dp[i | mask] = min(
                dp[i | mask],
                dp[i] + cost
            )

res = dp[-1] if dp[-1] != INF else -1
print(res)


Fixed submission:
n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = [INF] * (1 << n)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    mask = sum(1 << box for box in boxes)
    
    for i in range(1 << n):
        if dp[i] + cost < dp[i | mask]:
            dp[i | mask] = dp[i] + cost

res = dp[-1] if dp[-1] != INF else -1
print(res)

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


n, m = [int(x) for x in input().split()]

costs = []
masks = []

for _ in range(m):
    costs.append(int(input().split()[0]))

    boxes = {int(x)-1 for x in input().split()}
    mask = ['1' if idx in boxes else '0' for idx in range(n)][::-1]
    mask = int(''.join(mask), 2)
    masks.append(mask)

INF = int(10e8 + 1)
dp = np.full(1 << n, INF, dtype=int)
dp[0] = 0

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

res = dp[-1] if dp[-1] != INF else -1
print(res)


Fixed submission:
n, m = [int(x) for x in input().split()]

INF = int(10e8 + 1)
dp = [INF] * (1 << n)
dp[0] = 0

for j in range(m):
    cost = int(input().split()[0])

    boxes = [int(x)-1 for x in input().split()]
    mask = 0

    mask = sum(1 << box for box in boxes)
    
    for i in range(1 << n):
        if dp[i] + cost < dp[i | mask]:
            dp[i | mask] = dp[i] + cost

res = dp[-1] if dp[-1] != INF else -1
print(res)