import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
v = []
t = []

for _ in range(M):
    a, b = 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 sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from collections import * N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M v = [] v [] t = [] t [] for _ in range(M):
    a, b = 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) _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split v.append(a) v.append v append a ti = 0 ti 0 for i in range(b):
        ti += 1<<(c[i]-1)
    
     i range(b) range b ti += 1<<(c[i]-1) ti 1<<(c[i]-1) 1 c[i]-1 c[i] c i 1 t.append(ti) t.append t append ti dp = [10**18]*(1<<N) dp [10**18]*(1<<N) [10**18] 10**18 10 18 1<<N 1 N dp[0] = 0 dp[0] 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]) S range(1<<N) range 1<<N 1 N for i in range(M):
        dp[S|t[i]] = min(dp[S|t[i]], dp[S]+v[i]) i range(M) range M dp[S|t[i]] = min(dp[S|t[i]], dp[S]+v[i]) dp[S|t[i]] dp S|t[i] S t[i] t i min(dp[S|t[i]], dp[S]+v[i]) min dp[S|t[i]] dp S|t[i] S t[i] t i dp[S]+v[i] dp[S] dp S v[i] v i if dp[-1]==10**18:
    print(-1)
else:
    print(dp[-1]) dp[-1]==10**18 dp[-1] dp -1 10**18 10 18 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 a, b = map(int, input().split()) map(int, input().split()) a t = [] [] t v = [] [] v dp = [10**18]*(1<<N) [10**18]*(1<<N) dp ti = 0 0 ti M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N b = map(int, input().split()) map(int, input().split()) b c = list(map(int, input().split())) list(map(int, input().split())) c input = sys.stdin.readline sys.stdin.readline input ti += 1<<(c[i]-1) 1<<(c[i]-1) ti
import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
v = []
t = []

for _ in range(M):
    a, b = 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])