# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
price = [0] * m
can_opens = [0] * m
for i in range(m):
    a,b = list(map(int,input().split()))
    price[i]=a
    c = ["0"] * n
    ci = list(map(int,input().split()))
    for j in ci:
        c[n- j]="1"
    can_opens[i]=int("".join(c),2)
inf=float("inf")
dp = [inf] * 2**n
dp[0]=0
#dp[i]は、iを取るために必要な最小費用
for i,(pi,coi) in enumerate(zip(price,can_opens)):
    for j in range(2**n):
        dp[j|coi]=min(dp[j|coi],dp[j]+pi)
from math import isinf
if isinf(dp[-1]):
    print(-1)
else:
    print(dp[-1]) n,m = list(map(int,input().split())) n list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split m price = [0] * m price [0] * m [0] 0 m can_opens = [0] * m can_opens [0] * m [0] 0 m for i in range(m):
    a,b = list(map(int,input().split()))
    price[i]=a
    c = ["0"] * n
    ci = list(map(int,input().split()))
    for j in ci:
        c[n- j]="1"
    can_opens[i]=int("".join(c),2) i range(m) range m a,b = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split b price[i]=a price[i] price i a c = ["0"] * n c ["0"] * n ["0"] "0" n ci = list(map(int,input().split())) ci list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in ci:
        c[n- j]="1"
     j ci c[n- j]="1" c[n- j] c n- j n j "1" can_opens[i]=int("".join(c),2) can_opens[i] can_opens i int("".join(c),2) int "".join(c) "".join "" join c 2 inf=float("inf") inf float("inf") float "inf" dp = [inf] * 2**n dp [inf] * 2**n [inf] inf 2**n 2 n dp[0]=0 dp[0] dp 0 0 for i,(pi,coi) in enumerate(zip(price,can_opens)):
    for j in range(2**n):
        dp[j|coi]=min(dp[j|coi],dp[j]+pi) i (pi,coi) pi coi enumerate(zip(price,can_opens)) enumerate zip(price,can_opens) zip price can_opens for j in range(2**n):
        dp[j|coi]=min(dp[j|coi],dp[j]+pi) j range(2**n) range 2**n 2 n dp[j|coi]=min(dp[j|coi],dp[j]+pi) dp[j|coi] dp j|coi j coi min(dp[j|coi],dp[j]+pi) min dp[j|coi] dp j|coi j coi dp[j]+pi dp[j] dp j pi from math import isinf if isinf(dp[-1]):
    print(-1)
else:
    print(dp[-1]) isinf(dp[-1]) isinf dp[-1] dp -1 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 n,m = list(map(int,input().split())) list(map(int,input().split())) n dp = [inf] * 2**n [inf] * 2**n dp price = [0] * m [0] * m price can_opens = [0] * m [0] * m can_opens c = ["0"] * n ["0"] * n c b = list(map(int,input().split())) list(map(int,input().split())) b m = list(map(int,input().split())) list(map(int,input().split())) m ci = list(map(int,input().split())) list(map(int,input().split())) ci inf=float("inf") float("inf") inf a,b = list(map(int,input().split())) list(map(int,input().split())) a
# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
price = [0] * m
can_opens = [0] * m
for i in range(m):
    a,b = list(map(int,input().split()))
    price[i]=a
    c = ["0"] * n
    ci = list(map(int,input().split()))
    for j in ci:
        c[n- j]="1"
    can_opens[i]=int("".join(c),2)
inf=float("inf")
dp = [inf] * 2**n
dp[0]=0
#dp[i]は、iを取るために必要な最小費用
for i,(pi,coi) in enumerate(zip(price,can_opens)):
    for j in range(2**n):
        dp[j|coi]=min(dp[j|coi],dp[j]+pi)
from math import isinf
if isinf(dp[-1]):
    print(-1)
else:
    print(dp[-1])