Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())
    a = []
    c = []
    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for _ in range(m):
        a, b = map(int, input().split())
        sc = list(map(int, input().split()))
        c = 0
        for j in sc:
            c += 2 ** (j - 1)
        for j in range(2 ** n):
            dp[int(j | c)] = min(dp[int(j | c)], dp[j] + a)

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()


Fixed submission:
def main():
    n, m = map(int, input().split())
    a = []
    c = []
    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for _ in range(m):
        a, b = map(int, input().split())
        sc = list(map(int, input().split()))
        c = 0
        for j in sc:
            c += 2 ** (j - 1)
        for j in range(2 ** n):
            dp[j | c] = min(dp[j | c], dp[j] + a)

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())
    a = []
    c = []
    for i in range(m):
        sa, sb = map(int, input().split())
        sc = list(map(int, input().split()))
        tc = 0
        a.append(sa)
        for j in sc:
            tc += 2 ** (j - 1)
        c.append(tc)

    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for i in range(m):
        sc = c[i]
        for j in range(2 ** n):
            dp[int(j | sc)] = min(dp[int(j | sc)], dp[j] + a[i])

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()


Fixed submission:
def main():
    n, m = map(int, input().split())
    a = []
    c = []
    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for _ in range(m):
        a, b = map(int, input().split())
        sc = list(map(int, input().split()))
        c = 0
        for j in sc:
            c += 2 ** (j - 1)
        for j in range(2 ** n):
            dp[j | c] = min(dp[j | c], dp[j] + a)

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = []
c = []
for i in range(m):
    sa, sb = map(int, input().split())
    sc = list(map(int, input().split()))
    tc = 0
    a.append(sa)
    for j in sc:
        tc += 2 ** (j - 1)
    c.append(tc)

dp = [10 ** 7 for j in range(2 ** n)]
dp[0] = 0
for i in range(m):
    sc = c[i]
    for j in range(2 ** n):
        dp[int(j | sc)] = min(dp[int(j | sc)], dp[j] + a[i])

if dp[2 ** n - 1] == 10 ** 7:
    print(-1)
else:
    print(dp[2 ** n - 1])


Fixed submission:
def main():
    n, m = map(int, input().split())
    a = []
    c = []
    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for _ in range(m):
        a, b = map(int, input().split())
        sc = list(map(int, input().split()))
        c = 0
        for j in sc:
            c += 2 ** (j - 1)
        for j in range(2 ** n):
            dp[j | c] = min(dp[j | c], dp[j] + a)

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = []
c = []
for i in range(m):
    sa, sb = map(int, input().split())
    sc = list(map(int, input().split()))
    tc = 0
    a.append(sa)
    for j in sc:
        tc += 2 ** (j - 1)
    c.append(tc)

dp = [10 ** 7 for j in range(2 ** n)]
for i in range(m + 1):
    dp[0] = 0
for i in range(m):
    sc = c[i]
    for j in range(2 ** n):
        dp[int(j | sc)] = min(dp[int(j | sc)], dp[j] + a[i])

if dp[2 ** n - 1] == 10 ** 7:
    print(-1)
else:
    print(dp[2 ** n - 1])


Fixed submission:
def main():
    n, m = map(int, input().split())
    a = []
    c = []
    dp = [10 ** 7 for j in range(2 ** n)]
    dp[0] = 0
    for _ in range(m):
        a, b = map(int, input().split())
        sc = list(map(int, input().split()))
        c = 0
        for j in sc:
            c += 2 ** (j - 1)
        for j in range(2 ** n):
            dp[j | c] = min(dp[j | c], dp[j] + a)

    if dp[2 ** n - 1] == 10 ** 7:
        print(-1)
    else:
        print(dp[2 ** n - 1])


main()