N,M = map(int,input().split())
from collections import defaultdict
INF = float('inf')
dic = defaultdict(lambda: INF)
for i in range(M):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    d = 0
    for k in c:
        d |= (1<<(k-1))
    dic[d] = min(dic[d], a)

dp = [INF] * (1<<N)
dp[0] = 0
for k,v in dic.items():
    for b in range((1<<N)-1):
        if dp[b] == INF: continue
        if b == (b|k): continue
        dp[b|k] = min(dp[b|k], dp[b]+v)
print(-1 if dp[-1]==INF else dp[-1])                 N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M from collections import defaultdict INF = float('inf') INF float('inf') float 'inf' dic = defaultdict(lambda: INF) dic defaultdict(lambda: INF) defaultdict lambda: INF INF for i in range(M):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    d = 0
    for k in c:
        d |= (1<<(k-1))
    dic[d] = min(dic[d], a) i 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 d = 0 d 0 for k in c:
        d |= (1<<(k-1))
     k c d |= (1<<(k-1)) d 1<<(k-1) 1 k-1 k 1 dic[d] = min(dic[d], a) dic[d] dic d min(dic[d], a) min dic[d] dic d a dp = [INF] * (1<<N) dp [INF] * (1<<N) [INF] INF 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for k,v in dic.items():
    for b in range((1<<N)-1):
        if dp[b] == INF: continue
        if b == (b|k): continue
        dp[b|k] = min(dp[b|k], dp[b]+v) k v dic.items() dic.items dic items for b in range((1<<N)-1):
        if dp[b] == INF: continue
        if b == (b|k): continue
        dp[b|k] = min(dp[b|k], dp[b]+v) b range((1<<N)-1) range (1<<N)-1 1<<N 1 N 1 if dp[b] == INF: continue
         dp[b] == INF dp[b] dp b INF if b == (b|k): continue
         b == (b|k) b b|k b k dp[b|k] = min(dp[b|k], dp[b]+v) dp[b|k] dp b|k b k min(dp[b|k], dp[b]+v) min dp[b|k] dp b|k b k dp[b]+v dp[b] dp b v print(-1 if dp[-1]==INF else dp[-1]) print -1 if dp[-1]==INF else dp[-1] dp[-1]==INF dp[-1] dp -1 INF -1 dp[-1] dp -1 dp = [INF] * (1<<N) [INF] * (1<<N) dp M = map(int,input().split()) map(int,input().split()) M INF = float('inf') float('inf') INF b = map(int,input().split()) map(int,input().split()) b d = 0 0 d d |= (1<<(k-1)) 1<<(k-1) d a,b = map(int,input().split()) map(int,input().split()) a N,M = map(int,input().split()) map(int,input().split()) N dic = defaultdict(lambda: INF) defaultdict(lambda: INF) dic c = list(map(int,input().split())) list(map(int,input().split())) c
N,M = map(int,input().split())
from collections import defaultdict
INF = float('inf')
dic = defaultdict(lambda: INF)
for i in range(M):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    d = 0
    for k in c:
        d |= (1<<(k-1))
    dic[d] = min(dic[d], a)

dp = [INF] * (1<<N)
dp[0] = 0
for k,v in dic.items():
    for b in range((1<<N)-1):
        if dp[b] == INF: continue
        if b == (b|k): continue
        dp[b|k] = min(dp[b|k], dp[b]+v)
print(-1 if dp[-1]==INF else dp[-1])                