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



A = []

C = []

for i in range(M):

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

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

    A.append(a)

    d = 0

    for j in range(b):

        d += pow(2, c[j]-1)

    C.append(d)



goal = pow(2, N)-1

e_list = [[] for i in range(goal+1)]

for i in range(goal+1):

    for j in range(M):

        e_list[i].append((i|C[j],A[j]))

#dijkstra

#you need to prepare e_list = [[orient,dist]]



import heapq

vi = 0

min_d_list = [10**27 for i in range(goal+1)]

min_d_list[vi] = 0

q = []

for i in range(N):

    heapq.heappush(q,[min_d_list[i],i])



while len(q)>0:

    d,v = heapq.heappop(q)

    for e in e_list[v]:

        v1,d1=e

        if min_d_list[v1]>d+d1:

            min_d_list[v1]=d+d1

            heapq.heappush(q,[d+d1,v1])



if min_d_list[goal]>=10**27:

    print((-1))

else:

    print((min_d_list[goal]))
N,M = list(map(int,input().split()))



a_list = []

c_list = []



for i in range(M):

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

    a_list.append(a)

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

    d = 0

    for cc in c:

        d += 2**(cc-1)

    c_list.append(d)



DP = [[10**27]*(2**N) for i in range(M+1)]

DP[0][0]=0

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

    for j in range(2**N):

        #print(c_list[i-1] | j)

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

        DP[i][c_list[i-1] | j] = min(DP[i][c_list[i-1] | j],DP[i-1][j] + a_list[i-1])



#print(DP)

if DP[M][2**N-1]>=10**27:

    print((-1))

else:

    print((DP[M][2**N-1]))
N, M = list(map(int, input().split()))
A = []
C = []
for i in range(M):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    A.append(a)
    d = 0
    for j in range(b):
        d += pow(2, c[j] - 1)
    C.append(d)
goal = pow(2, N) - 1
e_list = [[] for i in range(goal + 1)]
for i in range(goal + 1):
    for j in range(M):
        e_list[i].append((i | C[j], A[j]))
# dijkstra
# you need to prepare e_list = [[orient,dist]]
import heapq

vi = 0
min_d_list = [10**27 for i in range(goal + 1)]
min_d_list[vi] = 0
q = []
for i in range(N):
    heapq.heappush(q, [min_d_list[i], i])
while len(q) > 0:
    d, v = heapq.heappop(q)
    for e in e_list[v]:
        v1, d1 = e
        if min_d_list[v1] > d + d1:
            min_d_list[v1] = d + d1
            heapq.heappush(q, [d + d1, v1])
if min_d_list[goal] >= 10**27:
    print((-1))
else:
    print((min_d_list[goal]))

N, M = list(map(int, input().split()))
a_list = []
c_list = []
for i in range(M):
    a, b = list(map(int, input().split()))
    a_list.append(a)
    c = list(map(int, input().split()))
    d = 0
    for cc in c:
        d += 2 ** (cc - 1)
    c_list.append(d)
DP = [[10**27] * (2**N) for i in range(M + 1)]
DP[0][0] = 0
for i in range(1, M + 1):
    for j in range(2**N):
        # print(c_list[i-1] | j)
        DP[i][j] = min(DP[i][j], DP[i - 1][j])
        DP[i][c_list[i - 1] | j] = min(
            DP[i][c_list[i - 1] | j], DP[i - 1][j] + a_list[i - 1]
        )
# print(DP)
if DP[M][2**N - 1] >= 10**27:
    print((-1))
else:
    print((DP[M][2**N - 1]))

-A = [] -C = [] +a_list = [] +c_list = [] +    a_list.append(a) -    A.append(a) -    for j in range(b): -        d += pow(2, c[j] - 1) -    C.append(d) -goal = pow(2, N) - 1 -e_list = [[] for i in range(goal + 1)] -for i in range(goal + 1): -    for j in range(M): -        e_list[i].append((i | C[j], A[j])) -# dijkstra -# you need to prepare e_list = [[orient,dist]] -import heapq - -vi = 0 -min_d_list = [10**27 for i in range(goal + 1)] -min_d_list[vi] = 0 -q = [] -for i in range(N): -    heapq.heappush(q, [min_d_list[i], i]) -while len(q) > 0: -    d, v = heapq.heappop(q) -    for e in e_list[v]: -        v1, d1 = e -        if min_d_list[v1] > d + d1: -            min_d_list[v1] = d + d1 -            heapq.heappush(q, [d + d1, v1]) -if min_d_list[goal] >= 10**27: +    for cc in c: +        d += 2 ** (cc - 1) +    c_list.append(d) +DP = [[10**27] * (2**N) for i in range(M + 1)] +DP[0][0] = 0 +for i in range(1, M + 1): +    for j in range(2**N): +        # print(c_list[i-1] | j) +        DP[i][j] = min(DP[i][j], DP[i - 1][j]) +        DP[i][c_list[i - 1] | j] = min( +            DP[i][c_list[i - 1] | j], DP[i - 1][j] + a_list[i - 1] +        ) +# print(DP) +if DP[M][2**N - 1] >= 10**27: -    print((min_d_list[goal])) +    print((DP[M][2**N - 1]))