N, M = list(map(int, input().split()))

A = [None] * M

K = [None] * M

for i in range(M):

    a, b = list(map(int, input().split()))

    C = list(map(int, input().split()))

    A[i] = a

    K[i] = sum([2 ** (i - 1) for i in C])





INF = (1 << 32) - 1

dp = [[INF] * (2 ** N) for _ in range(M + 1)]

for i in range(M + 1):

    dp[i][0] = 0



for i in range(M):

    k = K[i]

    a = A[i]

    for j in range(2 ** N):

        here = dp[i][j]

        dp[i + 1][j] = min(dp[i + 1][j], here)

        dp[i + 1][j | k] = min(dp[i + 1][j | k], dp[i][j | k], here + a)



ans = dp[M][2 ** N - 1] if dp[M][2 ** N - 1] < INF else -1

print(ans)

N, M = list(map(int, input().split()))

A = [None] * M

K = [None] * M

for i in range(M):

    a, b = list(map(int, input().split()))

    C = list(map(int, input().split()))

    A[i] = a

    K[i] = sum([2 ** (i - 1) for i in C])





INF = (1 << 32) - 1

dp = [INF] * (2 ** N)

dp[0] = 0



for i in range(M):

    k = K[i]

    a = A[i]

    for j in range(2 ** N):

        dp[j | k] = min(dp[j | k], dp[j] + a)



ans = dp[2 ** N - 1] if dp[2 ** N - 1] < INF else -1

print(ans)

N, M = list(map(int, input().split()))
A = [None] * M
K = [None] * M
for i in range(M):
    a, b = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A[i] = a
    K[i] = sum([2 ** (i - 1) for i in C])
INF = (1 << 32) - 1
dp = [[INF] * (2**N) for _ in range(M + 1)]
for i in range(M + 1):
    dp[i][0] = 0
for i in range(M):
    k = K[i]
    a = A[i]
    for j in range(2**N):
        here = dp[i][j]
        dp[i + 1][j] = min(dp[i + 1][j], here)
        dp[i + 1][j | k] = min(dp[i + 1][j | k], dp[i][j | k], here + a)
ans = dp[M][2**N - 1] if dp[M][2**N - 1] < INF else -1
print(ans)

N, M = list(map(int, input().split()))
A = [None] * M
K = [None] * M
for i in range(M):
    a, b = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A[i] = a
    K[i] = sum([2 ** (i - 1) for i in C])
INF = (1 << 32) - 1
dp = [INF] * (2**N)
dp[0] = 0
for i in range(M):
    k = K[i]
    a = A[i]
    for j in range(2**N):
        dp[j | k] = min(dp[j | k], dp[j] + a)
ans = dp[2**N - 1] if dp[2**N - 1] < INF else -1
print(ans)

-dp = [[INF] * (2**N) for _ in range(M + 1)] -for i in range(M + 1): -    dp[i][0] = 0 +dp = [INF] * (2**N) +dp[0] = 0 -        here = dp[i][j] -        dp[i + 1][j] = min(dp[i + 1][j], here) -        dp[i + 1][j | k] = min(dp[i + 1][j | k], dp[i][j | k], here + a) -ans = dp[M][2**N - 1] if dp[M][2**N - 1] < INF else -1 +        dp[j | k] = min(dp[j | k], dp[j] + a) +ans = dp[2**N - 1] if dp[2**N - 1] < INF else -1