import itertools

import sys

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 7)



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

AB = []

C = []

for _ in range(M):

    AB.append(tuple(int(x) for x in readline().split()))

    C.append(sum(1 << (int(x)-1) for x in readline().split()))



INF = 10**18

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

dp[0] = 0



for n, ((a, b), c) in itertools.product(list(range(1 << N)), list(zip(AB, C))):

    m = n | c

    x = dp[n]+a

    if dp[m] > x:

      dp[m] = x



answer = dp[-1]

if answer == INF:

    answer = -1

print(answer)

#!/usr/bin/env python3

import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

inf = float('inf') ;mod = 10**9+7

mans = inf ;ans = 0 ;count = 0 ;pro = 1



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

A=[0]*(m+1); S=[0]*m



for i in range(m):

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

    A[i]=a

    s=0

    for ci in map(int,input().split()):

        s|=1<<(ci-1)

    S[i]=s

dp=[[inf]*(2**n) for i in range(m+1)]

for i in range(m+1):

    dp[i][0]=0

# print(dp)

# print(S)

for i in range(m):

    for s in range(2**n):

        dp[i+1][s]=min(dp[i+1][s],dp[i][s])

        # if i==1 and s==0:

        #     print(i,s,S[i])

        #     print(dp[i+1][s|S[i]],dp[i+1][s|S[i]],dp[i][s|S[i]],dp[i][s]+A[i])

        dp[i+1][s|S[i]]=min(dp[i+1][s|S[i]],dp[i][s|S[i]],dp[i][s]+A[i])

print((dp[m][(1 << n)-1] if dp[m][(1 << n)-1] != inf else -1))

# print(S)

# for di in dp:

#     print(*di)
import itertools
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**7)
N, M = list(map(int, readline().split()))
AB = []
C = []
for _ in range(M):
    AB.append(tuple(int(x) for x in readline().split()))
    C.append(sum(1 << (int(x) - 1) for x in readline().split()))
INF = 10**18
dp = [INF] * (1 << N)
dp[0] = 0
for n, ((a, b), c) in itertools.product(list(range(1 << N)), list(zip(AB, C))):
    m = n | c
    x = dp[n] + a
    if dp[m] > x:
        dp[m] = x
answer = dp[-1]
if answer == INF:
    answer = -1
print(answer)

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
n, m = list(map(int, input().split()))
A = [0] * (m + 1)
S = [0] * m
for i in range(m):
    a, b = list(map(int, input().split()))
    A[i] = a
    s = 0
    for ci in map(int, input().split()):
        s |= 1 << (ci - 1)
    S[i] = s
dp = [[inf] * (2**n) for i in range(m + 1)]
for i in range(m + 1):
    dp[i][0] = 0
# print(dp)
# print(S)
for i in range(m):
    for s in range(2**n):
        dp[i + 1][s] = min(dp[i + 1][s], dp[i][s])
        # if i==1 and s==0:
        #     print(i,s,S[i])
        #     print(dp[i+1][s|S[i]],dp[i+1][s|S[i]],dp[i][s|S[i]],dp[i][s]+A[i])
        dp[i + 1][s | S[i]] = min(dp[i + 1][s | S[i]], dp[i][s | S[i]], dp[i][s] + A[i])
print((dp[m][(1 << n) - 1] if dp[m][(1 << n) - 1] != inf else -1))
# print(S)
# for di in dp:
#     print(*di)

-import itertools -import sys +#!/usr/bin/env python3 +import sys, math, itertools, collections, bisect -readline = sys.stdin.readline -readlines = sys.stdin.readlines -sys.setrecursionlimit(10**7) -N, M = list(map(int, readline().split())) -AB = [] -C = [] -for _ in range(M): -    AB.append(tuple(int(x) for x in readline().split())) -    C.append(sum(1 << (int(x) - 1) for x in readline().split())) -INF = 10**18 -dp = [INF] * (1 << N) -dp[0] = 0 -for n, ((a, b), c) in itertools.product(list(range(1 << N)), list(zip(AB, C))): -    m = n | c -    x = dp[n] + a -    if dp[m] > x: -        dp[m] = x -answer = dp[-1] -if answer == INF: -    answer = -1 -print(answer) +input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") +inf = float("inf") +mod = 10**9 + 7 +mans = inf +ans = 0 +count = 0 +pro = 1 +n, m = list(map(int, input().split())) +A = [0] * (m + 1) +S = [0] * m +for i in range(m): +    a, b = list(map(int, input().split())) +    A[i] = a +    s = 0 +    for ci in map(int, input().split()): +        s |= 1 << (ci - 1) +    S[i] = s +dp = [[inf] * (2**n) for i in range(m + 1)] +for i in range(m + 1): +    dp[i][0] = 0 +# print(dp) +# print(S) +for i in range(m): +    for s in range(2**n): +        dp[i + 1][s] = min(dp[i + 1][s], dp[i][s]) +        # if i==1 and s==0: +        #     print(i,s,S[i]) +        #     print(dp[i+1][s|S[i]],dp[i+1][s|S[i]],dp[i][s|S[i]],dp[i][s]+A[i]) +        dp[i + 1][s | S[i]] = min(dp[i + 1][s | S[i]], dp[i][s | S[i]], dp[i][s] + A[i]) +print((dp[m][(1 << n) - 1] if dp[m][(1 << n) - 1] != inf else -1)) +# print(S) +# for di in dp: +#     print(*di)