import sys

#input = sys.stdin.readline



INF = 10**12

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

K = []

for i in range(M) :

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

    s = 0 #setをbitで管理.

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

    for c in cx :

        s = s | (1 << (c-1)) #setの和集合

    K.append([s, a])



#dp[bit]: 集合=bit のときのコストの最小値

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

dp[0] = 0



for bit in range(1 << N) :

    for i in range(M) :

        s,a = K[i]

        t = bit | s

        cost = dp[bit] + a

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

ans = -1 if dp[-1] == INF else dp[-1]



print(ans)

import sys

input = sys.stdin.readline



INF = 10**12

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

K = []

for i in range(M) :

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

    s = 0 #setをbitで管理.

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

    for c in cx :

        s = s | (1 << (c-1)) #setの和集合

    K.append([s, a])



#dp[bit]: 集合=bit のときのコストの最小値

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

dp[0] = 0



for bit in range(1 << N) :

    for i in range(M) :

        s,a = K[i]

        t = bit | s

        cost = dp[bit] + a

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

ans = -1 if dp[-1] == INF else dp[-1]



print(ans)

import sys

# input = sys.stdin.readline
INF = 10**12
N, M = list(map(int, input().split()))
K = []
for i in range(M):
    a, b = list(map(int, input().split()))
    s = 0  # setをbitで管理.
    cx = list(map(int, input().split()))
    for c in cx:
        s = s | (1 << (c - 1))  # setの和集合
    K.append([s, a])
# dp[bit]: 集合=bit のときのコストの最小値
dp = [INF] * (1 << N)
dp[0] = 0
for bit in range(1 << N):
    for i in range(M):
        s, a = K[i]
        t = bit | s
        cost = dp[bit] + a
        dp[t] = min(dp[t], cost)
ans = -1 if dp[-1] == INF else dp[-1]
print(ans)

import sys

input = sys.stdin.readline
INF = 10**12
N, M = list(map(int, input().split()))
K = []
for i in range(M):
    a, b = list(map(int, input().split()))
    s = 0  # setをbitで管理.
    cx = list(map(int, input().split()))
    for c in cx:
        s = s | (1 << (c - 1))  # setの和集合
    K.append([s, a])
# dp[bit]: 集合=bit のときのコストの最小値
dp = [INF] * (1 << N)
dp[0] = 0
for bit in range(1 << N):
    for i in range(M):
        s, a = K[i]
        t = bit | s
        cost = dp[bit] + a
        dp[t] = min(dp[t], cost)
ans = -1 if dp[-1] == INF else dp[-1]
print(ans)

-# input = sys.stdin.readline +input = sys.stdin.readline