import sys

input = sys.stdin.readline

from collections import *



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

v = []

t = []



for _ in range(M):

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

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

    v.append(a)

    ti = 0

    

    for i in range(b):

        ti += 1<<(c[i]-1)

    

    t.append(ti)



dp = [10**18]*(1<<N)

dp[0] = 0



for S in range(1<<N):

    for i in range(M):

        dp[S|t[i]] = min(dp[S|t[i]], dp[S]+v[i])



if dp[-1]==10**18:

    print((-1))

else:

    print((dp[-1]))
import sys

input = sys.stdin.readline



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

ks = []



for _ in range(M):

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

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

    T = 0

    

    for ci in c:

        T += 1<<(ci-1)

    

    ks.append((a, T))



dp = [10**18]*(1<<N)

dp[0] = 0



for S in range(1<<N):

    for a, T in ks:

        dp[S|T] = min(dp[S|T], dp[S]+a)



if dp[-1]==10**18:

    print((-1))

else:

    print((dp[-1]))
import sys

input = sys.stdin.readline
from collections import *

N, M = list(map(int, input().split()))
v = []
t = []
for _ in range(M):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    v.append(a)
    ti = 0
    for i in range(b):
        ti += 1 << (c[i] - 1)
    t.append(ti)
dp = [10**18] * (1 << N)
dp[0] = 0
for S in range(1 << N):
    for i in range(M):
        dp[S | t[i]] = min(dp[S | t[i]], dp[S] + v[i])
if dp[-1] == 10**18:
    print((-1))
else:
    print((dp[-1]))

import sys

input = sys.stdin.readline
N, M = list(map(int, input().split()))
ks = []
for _ in range(M):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    T = 0
    for ci in c:
        T += 1 << (ci - 1)
    ks.append((a, T))
dp = [10**18] * (1 << N)
dp[0] = 0
for S in range(1 << N):
    for a, T in ks:
        dp[S | T] = min(dp[S | T], dp[S] + a)
if dp[-1] == 10**18:
    print((-1))
else:
    print((dp[-1]))

-from collections import * - -v = [] -t = [] +ks = [] -    v.append(a) -    ti = 0 -    for i in range(b): -        ti += 1 << (c[i] - 1) -    t.append(ti) +    T = 0 +    for ci in c: +        T += 1 << (ci - 1) +    ks.append((a, T)) -    for i in range(M): -        dp[S | t[i]] = min(dp[S | t[i]], dp[S] + v[i]) +    for a, T in ks: +        dp[S | T] = min(dp[S | T], dp[S] + a)