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

INF = float('inf')

V = [INF] * (1<<N)

V[0] = 0

for i in range(M):

    v,_ = list(map(int,input().split()))

    b = 0

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

    for a in s:

        b |= (1<<(a-1))

    V[b] = min(V[b], v)



vbs = []

for b,v in enumerate(V):

    if v==INF: continue

    vbs.append((v,b))



for v,b in vbs:

    for c in range(1<<N):

        if V[c] == INF: continue

        V[b|c] = min(V[b|c], V[b]+V[c])



print((V[-1] if V[-1] < INF else -1))
N,M = list(map(int,input().split()))

from collections import defaultdict

INF = float('inf')

dic = defaultdict(lambda: INF)

for i in range(M):

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

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

    d = 0

    for k in c:

        d |= (1<<(k-1))

    dic[d] = min(dic[d], a)



dp = [INF] * (1<<N)

dp[0] = 0

for k,v in list(dic.items()):

    for b in range((1<<N)-1):

        if dp[b] == INF: continue

        if b == (b|k): continue

        dp[b|k] = min(dp[b|k], dp[b]+v)

print((-1 if dp[-1]==INF else dp[-1]))                
N, M = list(map(int, input().split()))
INF = float("inf")
V = [INF] * (1 << N)
V[0] = 0
for i in range(M):
    v, _ = list(map(int, input().split()))
    b = 0
    s = list(map(int, input().split()))
    for a in s:
        b |= 1 << (a - 1)
    V[b] = min(V[b], v)
vbs = []
for b, v in enumerate(V):
    if v == INF:
        continue
    vbs.append((v, b))
for v, b in vbs:
    for c in range(1 << N):
        if V[c] == INF:
            continue
        V[b | c] = min(V[b | c], V[b] + V[c])
print((V[-1] if V[-1] < INF else -1))

N, M = list(map(int, input().split()))
from collections import defaultdict

INF = float("inf")
dic = defaultdict(lambda: INF)
for i in range(M):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    d = 0
    for k in c:
        d |= 1 << (k - 1)
    dic[d] = min(dic[d], a)
dp = [INF] * (1 << N)
dp[0] = 0
for k, v in list(dic.items()):
    for b in range((1 << N) - 1):
        if dp[b] == INF:
            continue
        if b == (b | k):
            continue
        dp[b | k] = min(dp[b | k], dp[b] + v)
print((-1 if dp[-1] == INF else dp[-1]))

+from collections import defaultdict + -V = [INF] * (1 << N) -V[0] = 0 +dic = defaultdict(lambda: INF) -    v, _ = list(map(int, input().split())) -    b = 0 -    s = list(map(int, input().split())) -    for a in s: -        b |= 1 << (a - 1) -    V[b] = min(V[b], v) -vbs = [] -for b, v in enumerate(V): -    if v == INF: -        continue -    vbs.append((v, b)) -for v, b in vbs: -    for c in range(1 << N): -        if V[c] == INF: +    a, b = list(map(int, input().split())) +    c = list(map(int, input().split())) +    d = 0 +    for k in c: +        d |= 1 << (k - 1) +    dic[d] = min(dic[d], a) +dp = [INF] * (1 << N) +dp[0] = 0 +for k, v in list(dic.items()): +    for b in range((1 << N) - 1): +        if dp[b] == INF: -        V[b | c] = min(V[b | c], V[b] + V[c]) -print((V[-1] if V[-1] < INF else -1)) +        if b == (b | k): +            continue +        dp[b | k] = min(dp[b | k], dp[b] + v) +print((-1 if dp[-1] == INF else dp[-1]))