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

INF = float("inf")

key = []

for i in range(M):

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

    f = 0

    for c in list(map(int, input().split())):

        c -= 1

        f |= 1 << c

    key.append((f, a))

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

dp[0] = 0

 

for f in range(1 << N): 

    for i in range(M):

        t = f | key[i][0]

        cost = dp[f] + key[i][1]

        dp[t] = min(dp[t], cost)



ans = dp[-1]

if ans == INF:

    ans = -1

 

print(ans)
n,m=list(map(int,input().split()))

INF=10**10

dp=[[INF]*(1<<n) for _ in range(m+1)]

for i in range(m+1):

    dp[i][0]=0

a=[0]

key=[0]

for i in range(m):

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

    a.append(a0)

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

    tmp=0

    for j in c:

        tmp+=1<<(j-1)

    key.append(tmp)



for i in range(1,m+1):

    for j in range(1<<n):

        if dp[i-1][j]<INF:

            dp[i][j]=min(dp[i][j],dp[i-1][j])

            dp[i][j|key[i]]=min(dp[i][j|key[i]],dp[i-1][j|key[i]],dp[i-1][j]+a[i])



ans=dp[-1][-1]

if ans!=INF:

    print(ans)

else:print((-1))

N, M = list(map(int, input().split()))
INF = float("inf")
key = []
for i in range(M):
    a, b = list(map(int, input().split()))
    f = 0
    for c in list(map(int, input().split())):
        c -= 1
        f |= 1 << c
    key.append((f, a))
dp = [INF] * (1 << N)
dp[0] = 0
for f in range(1 << N):
    for i in range(M):
        t = f | key[i][0]
        cost = dp[f] + key[i][1]
        dp[t] = min(dp[t], cost)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)

n, m = list(map(int, input().split()))
INF = 10**10
dp = [[INF] * (1 << n) for _ in range(m + 1)]
for i in range(m + 1):
    dp[i][0] = 0
a = [0]
key = [0]
for i in range(m):
    a0, b = list(map(int, input().split()))
    a.append(a0)
    (*c,) = list(map(int, input().split()))
    tmp = 0
    for j in c:
        tmp += 1 << (j - 1)
    key.append(tmp)
for i in range(1, m + 1):
    for j in range(1 << n):
        if dp[i - 1][j] < INF:
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            dp[i][j | key[i]] = min(
                dp[i][j | key[i]], dp[i - 1][j | key[i]], dp[i - 1][j] + a[i]
            )
ans = dp[-1][-1]
if ans != INF:
    print(ans)
else:
    print((-1))

-N, M = list(map(int, input().split())) -INF = float("inf") -key = [] -for i in range(M): -    a, b = list(map(int, input().split())) -    f = 0 -    for c in list(map(int, input().split())): -        c -= 1 -        f |= 1 << c -    key.append((f, a)) -dp = [INF] * (1 << N) -dp[0] = 0 -for f in range(1 << N): -    for i in range(M): -        t = f | key[i][0] -        cost = dp[f] + key[i][1] -        dp[t] = min(dp[t], cost) -ans = dp[-1] -if ans == INF: -    ans = -1 -print(ans) +n, m = list(map(int, input().split())) +INF = 10**10 +dp = [[INF] * (1 << n) for _ in range(m + 1)] +for i in range(m + 1): +    dp[i][0] = 0 +a = [0] +key = [0] +for i in range(m): +    a0, b = list(map(int, input().split())) +    a.append(a0) +    (*c,) = list(map(int, input().split())) +    tmp = 0 +    for j in c: +        tmp += 1 << (j - 1) +    key.append(tmp) +for i in range(1, m + 1): +    for j in range(1 << n): +        if dp[i - 1][j] < INF: +            dp[i][j] = min(dp[i][j], dp[i - 1][j]) +            dp[i][j | key[i]] = min( +                dp[i][j | key[i]], dp[i - 1][j | key[i]], dp[i - 1][j] + a[i] +            ) +ans = dp[-1][-1] +if ans != INF: +    print(ans) +else: +    print((-1))