Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    a = []
    b = []
    c = []
    for i in range(M):
        a_, b_ = map(int, input().split())
        a.append(a_)
        b.append(b_)
        c_ = np.array(list(map(int, input().split()))) - 1
        c.append(c_)

    INF = int(1e10)
    dp = [INF] * (1 << N)
    dp[0] = 0

    for i in range(M):
        key = 0
        for j in range(b[i]):
            key |= (1 << c[i][j])
        for bits in range(1 << N):
            dp[bits | key] = min(dp[bits | key], dp[bits] + a[i])
    
    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])

if __name__ == "__main__":
    main()

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    INF = int(1e10)
    dp = [INF] * (1 << N)
    dp[0] = 0
    bits = set()
    bits.add(0)
    for i in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        key = 0
        for t in c:
            key += 1 << (t - 1)
        add_bits = set()
        for bit in bits:
            tmp = bit | key
            if dp[bit] + a < dp[tmp]:
                dp[tmp] = dp[bit] + a
                add_bits.add(tmp)
        bits |= add_bits
    
    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    abc = []
    for i in range(M):
        a, b = map(int, input().split())
        c = np.array(list(map(int, input().split()))) - 1
        abc.append((a, b, c))
    abc = sorted(abc)
    INF = int(1e10)
    dp = np.full(N, INF, dtype=int)

    ans = 0
    for i in range(M):
        # print(dp)
        a, b, c = abc[i]
        if any(dp[c] == INF):
            dp[c] = np.minimum(dp[c], a)
            ans += a

    ok = True
    for i in range(N):
        if dp[i] == INF:
            ok = False
            break
    
    if ok:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    INF = int(1e10)
    dp = [INF] * (1 << N)
    dp[0] = 0
    bits = set()
    bits.add(0)
    for i in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        key = 0
        for t in c:
            key += 1 << (t - 1)
        add_bits = set()
        for bit in bits:
            tmp = bit | key
            if dp[bit] + a < dp[tmp]:
                dp[tmp] = dp[bit] + a
                add_bits.add(tmp)
        bits |= add_bits
    
    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    abc = []
    for i in range(M):
        a, b = map(int, input().split())
        c = np.array(list(map(int, input().split()))) - 1
        abc.append((a, b, c))
    abc = sorted(abc)
    INF = int(1e10)
    dp = np.full(N, INF, dtype=int)

    ans = 0
    for i in range(M):
        print(dp)
        a, b, c = abc[i]
        if any(dp[c] == INF):
            dp[c] = np.minimum(dp[c], a)
            ans += a

    ok = True
    for i in range(N):
        if dp[i] == INF:
            ok = False
            break
    
    if ok:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    INF = int(1e10)
    dp = [INF] * (1 << N)
    dp[0] = 0
    bits = set()
    bits.add(0)
    for i in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        key = 0
        for t in c:
            key += 1 << (t - 1)
        add_bits = set()
        for bit in bits:
            tmp = bit | key
            if dp[bit] + a < dp[tmp]:
                dp[tmp] = dp[bit] + a
                add_bits.add(tmp)
        bits |= add_bits
    
    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    abc = []
    for i in range(M):
        a, b = map(int, input().split())
        c = np.array(list(map(int, input().split()))) - 1
        abc.append((a, b, c))
    abc = sorted(abc)
    INF = int(1e10)
    dp = np.full(N, INF, dtype=int)

    ans = 0
    for i in range(M):
        a, b, c = abc[i]
        now = sum(dp[c])
        if now >= INF:
            dp[c] = np.minimum(dp[c], a)
            ans += a

    ok = True
    for i in range(N):
        if dp[i] == INF:
            ok = False
            break
    
    if ok:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    INF = int(1e10)
    dp = [INF] * (1 << N)
    dp[0] = 0
    bits = set()
    bits.add(0)
    for i in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        key = 0
        for t in c:
            key += 1 << (t - 1)
        add_bits = set()
        for bit in bits:
            tmp = bit | key
            if dp[bit] + a < dp[tmp]:
                dp[tmp] = dp[bit] + a
                add_bits.add(tmp)
        bits |= add_bits
    
    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    abc = []
    for i in range(M):
        a, b = map(int, input().split())
        c = np.array(list(map(int, input().split()))) - 1
        abc.append((a, b, c))
    abc = sorted(abc)
    INF = int(1e10)
    dp = np.full(N, INF, dtype=int)

    ans = 0
    for i in range(M):
        a, b, c = abc[i]
        now = sum(dp[c])
        if a < now:
            dp[c] = np.minimum(dp[c], a)
            ans += a

    ok = True
    for i in range(N):
        if dp[i] == INF:
            ok = False
            break
    
    if ok:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    INF = int(1e10)
    dp = [INF] * (1 << N)
    dp[0] = 0
    bits = set()
    bits.add(0)
    for i in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        key = 0
        for t in c:
            key += 1 << (t - 1)
        add_bits = set()
        for bit in bits:
            tmp = bit | key
            if dp[bit] + a < dp[tmp]:
                dp[tmp] = dp[bit] + a
                add_bits.add(tmp)
        bits |= add_bits
    
    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])

if __name__ == "__main__":
    main()