n,m=map(int,input().split())
dp=[float("inf")]*(1<<n)
b=[True]*(1<<n)
p=[]
k=0
for i in range(m):
    k=0
    a,_=map(int,input().split())
    c=list(map(int,input().split()))
    for cc in c:
        k+=1<<(cc-1)
    if b[k]:
        b[k]=False
    dp[k]=min(dp[k],a)
    p.append(k)
while True:
    d=[]
    for i in p:
        for j in p:
            if dp[i|j]>dp[i]+dp[j]:
                dp[i|j]=dp[i]+dp[j]
                if b[i|j]:
                    b[i|j]=False
                    d.append(i|j)
    if len(d)==0:
        break
    for oo in d:
        p.append(oo)
if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m dp=[float("inf")]*(1<<n) dp [float("inf")]*(1<<n) [float("inf")] float("inf") float "inf" 1<<n 1 n b=[True]*(1<<n) b [True]*(1<<n) [True] True 1<<n 1 n p=[] p [] k=0 k 0 for i in range(m):
    k=0
    a,_=map(int,input().split())
    c=list(map(int,input().split()))
    for cc in c:
        k+=1<<(cc-1)
    if b[k]:
        b[k]=False
    dp[k]=min(dp[k],a)
    p.append(k) i range(m) range m k=0 k 0 a,_=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split _ c=list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for cc in c:
        k+=1<<(cc-1)
     cc c k+=1<<(cc-1) k 1<<(cc-1) 1 cc-1 cc 1 if b[k]:
        b[k]=False
     b[k] b k b[k]=False b[k] b k False dp[k]=min(dp[k],a) dp[k] dp k min(dp[k],a) min dp[k] dp k a p.append(k) p.append p append k while True:
    d=[]
    for i in p:
        for j in p:
            if dp[i|j]>dp[i]+dp[j]:
                dp[i|j]=dp[i]+dp[j]
                if b[i|j]:
                    b[i|j]=False
                    d.append(i|j)
    if len(d)==0:
        break
    for oo in d:
        p.append(oo) True d=[] d [] for i in p:
        for j in p:
            if dp[i|j]>dp[i]+dp[j]:
                dp[i|j]=dp[i]+dp[j]
                if b[i|j]:
                    b[i|j]=False
                    d.append(i|j)
     i p for j in p:
            if dp[i|j]>dp[i]+dp[j]:
                dp[i|j]=dp[i]+dp[j]
                if b[i|j]:
                    b[i|j]=False
                    d.append(i|j)
     j p if dp[i|j]>dp[i]+dp[j]:
                dp[i|j]=dp[i]+dp[j]
                if b[i|j]:
                    b[i|j]=False
                    d.append(i|j)
     dp[i|j]>dp[i]+dp[j] dp[i|j] dp i|j i j dp[i]+dp[j] dp[i] dp i dp[j] dp j dp[i|j]=dp[i]+dp[j] dp[i|j] dp i|j i j dp[i]+dp[j] dp[i] dp i dp[j] dp j if b[i|j]:
                    b[i|j]=False
                    d.append(i|j)
     b[i|j] b i|j i j b[i|j]=False b[i|j] b i|j i j False d.append(i|j) d.append d append i|j i j if len(d)==0:
        break
     len(d)==0 len(d) len d 0 break for oo in d:
        p.append(oo) oo d p.append(oo) p.append p append oo if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1]) dp[-1]==float("inf") dp[-1] dp -1 float("inf") float "inf" print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 b=[True]*(1<<n) [True]*(1<<n) b dp=[float("inf")]*(1<<n) [float("inf")]*(1<<n) dp k=0 0 k n,m=map(int,input().split()) map(int,input().split()) n d=[] [] d a,_=map(int,input().split()) map(int,input().split()) a m=map(int,input().split()) map(int,input().split()) m _=map(int,input().split()) map(int,input().split()) _ k=0 0 k c=list(map(int,input().split())) list(map(int,input().split())) c p=[] [] p k+=1<<(cc-1) 1<<(cc-1) k
n,m=map(int,input().split())
dp=[float("inf")]*(1<<n)
b=[True]*(1<<n)
p=[]
k=0
for i in range(m):
    k=0
    a,_=map(int,input().split())
    c=list(map(int,input().split()))
    for cc in c:
        k+=1<<(cc-1)
    if b[k]:
        b[k]=False
    dp[k]=min(dp[k],a)
    p.append(k)
while True:
    d=[]
    for i in p:
        for j in p:
            if dp[i|j]>dp[i]+dp[j]:
                dp[i|j]=dp[i]+dp[j]
                if b[i|j]:
                    b[i|j]=False
                    d.append(i|j)
    if len(d)==0:
        break
    for oo in d:
        p.append(oo)
if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1])