Buggy python submission (verdict: Time Limit Exceeded):
import math
N, M = list(map(int, input().split(" ")))
abc = [[0, 0, 0] for i in range(M)]
for i in range(M):
  abc[i][0], abc[i][1] = list(map(int, input().split(" ")))
  c = list(map(int, input().split(" ")))
  for j in range(N):
    cbits = (1 << j) * (j+1 in c)
    abc[i][2] |= cbits

dp = [0 if i == 0 else float("inf") for i in range(2**N)]
for i in range(M):
  for j in range(2**N):
    dp[j|abc[i][2]] = min(dp[j]+abc[i][0], dp[j|abc[i][2]])
print(dp[-1] if dp[-1] != float("inf") else -1)

Fixed submission:
N, M = list(map(int, input().split(" ")))
abc = [[0, 0, 0] for i in range(M)]
for i in range(M):
  abc[i][0], abc[i][1] = list(map(int, input().split(" ")))
  c = list(map(int, input().split(" ")))
  for j in c:
    cbits = (1 << j-1) 
    abc[i][2] |= cbits

dp = [0 if i == 0 else float("inf") for i in range(2**N)]
for i in range(M):
  for j in range(2**N):
    if dp[j|abc[i][2]] > dp[j]+abc[i][0]:
      dp[j|abc[i][2]] = dp[j]+abc[i][0]
print(dp[-1] if dp[-1] != float("inf") else -1)

Buggy python submission (verdict: Runtime Error):
import math
N, M = list(map(int, input().split(" ")))
abc = [[0, 0, 0] for i in range(M)]
for i in range(M):
  abc[i][0], abc[i][1] = list(map(int, input().split(" ")))
  c = list(map(int, input().split(" ")))
  for j in range(N):
    cbits = (1 << j) * (j+1 in c)
    abc[i][2] |= cbits

dp = [0 if i == 0 else math.inf for i in range(2**N)]
for i in range(M):
  for j in range(2**N):
    dp[j|abc[i][2]] = min(dp[j]+abc[i][0], dp[j|abc[i][2]])
print(dp[-1] if dp[-1] != math.inf else -1)

Fixed submission:
N, M = list(map(int, input().split(" ")))
abc = [[0, 0, 0] for i in range(M)]
for i in range(M):
  abc[i][0], abc[i][1] = list(map(int, input().split(" ")))
  c = list(map(int, input().split(" ")))
  for j in c:
    cbits = (1 << j-1) 
    abc[i][2] |= cbits

dp = [0 if i == 0 else float("inf") for i in range(2**N)]
for i in range(M):
  for j in range(2**N):
    if dp[j|abc[i][2]] > dp[j]+abc[i][0]:
      dp[j|abc[i][2]] = dp[j]+abc[i][0]
print(dp[-1] if dp[-1] != float("inf") else -1)

Buggy python submission (verdict: Runtime Error):
import math
N, M = list(map(int, input().split(" ")))
abc = [[0, 0, 0] for i in range(M)]
for i in range(M):
  abc[i][0], abc[i][1] = list(map(int, input().split(" ")))
  c = list(map(int, input().split(" ")))
  for j in range(N):
    cbits = (1 << j) * (j+1 in c)
    abc[i][2] |= cbits

dp = [0 if i == 0 else math.inf for i in range(2**N)]
for i in range(M):
  for j in range(2**N):
    dp[j|abc[i][2]] = min(dp[j]+abc[i][0], dp[j|abc[i][2]])
print(dp[-1] if dp[-1] != math.inf else -1)

Fixed submission:
N, M = list(map(int, input().split(" ")))
abc = [[0, 0, 0] for i in range(M)]
for i in range(M):
  abc[i][0], abc[i][1] = list(map(int, input().split(" ")))
  c = list(map(int, input().split(" ")))
  for j in c:
    cbits = (1 << j-1) 
    abc[i][2] |= cbits

dp = [0 if i == 0 else float("inf") for i in range(2**N)]
for i in range(M):
  for j in range(2**N):
    if dp[j|abc[i][2]] > dp[j]+abc[i][0]:
      dp[j|abc[i][2]] = dp[j]+abc[i][0]
print(dp[-1] if dp[-1] != float("inf") else -1)

Buggy python submission (verdict: Runtime Error):
import math
N, M = list(map(int, input().split(" ")))
abc = [[0, 0, 0] for i in range(M)]
for i in range(M):
  abc[i][0], abc[i][1] = list(map(int, input().split(" ")))
  c = list(map(int, input().split(" ")))
  for j in range(N):
    cbits = (1 << j) * (j+1 in c)
    abc[i][2] |= cbits

dp = [0 if i == 0 else math.inf for i in range(2**N)]
for i in range(M):
  for j in range(2**N):
    dp[j|AB[i][2]] = min(dp[j]+AB[i][0], dp[j|AB[i][2]])
print(dp[-1] if dp[-1] != math.inf else -1)

Fixed submission:
N, M = list(map(int, input().split(" ")))
abc = [[0, 0, 0] for i in range(M)]
for i in range(M):
  abc[i][0], abc[i][1] = list(map(int, input().split(" ")))
  c = list(map(int, input().split(" ")))
  for j in c:
    cbits = (1 << j-1) 
    abc[i][2] |= cbits

dp = [0 if i == 0 else float("inf") for i in range(2**N)]
for i in range(M):
  for j in range(2**N):
    if dp[j|abc[i][2]] > dp[j]+abc[i][0]:
      dp[j|abc[i][2]] = dp[j]+abc[i][0]
print(dp[-1] if dp[-1] != float("inf") else -1)