Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N, M = map(int, input().split())
  inf =  10**9
  p = 1<<N
  dp = [[inf]*p for _ in range(M+1)]
  for i in range(M+1):
    dp[i][0] = 0
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([1<<(c-1) for c in C])
    for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
      dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()  

Fixed submission:
N, M = map(int, input().split())
inf =  10**9
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N, M = map(int, input().split())
  inf =  10**9
  p = 2**N
  dp = [[inf]*p for _ in range(M+1)]
  for i in range(M+1):
    dp[i][0] = 0
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(p):
      #print(min(dp[i][j|c_bit], dp[i][j] + a))
      dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
      dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()
        

Fixed submission:
N, M = map(int, input().split())
inf =  10**9
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
inf =  10**9
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()
        

Fixed submission:
N, M = map(int, input().split())
inf =  10**9
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
inf =  10**15
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()
        

Fixed submission:
N, M = map(int, input().split())
inf =  10**9
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()