n,m=map(int,input().split())
ans=[float("inf")]*(2**n)
ans[0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    tmp=0
    for j in c:
        tmp+=2**(j-1)
    na=ans.copy()
    for j in range(2**n):
        if ans[j|tmp]>na[j]+a:
            ans[j|tmp]=na[j]+a
if ans[2**n-1]==float("inf"):
    print(-1)
else:
    print(ans[2**n-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ans=[float("inf")]*(2**n) ans [float("inf")]*(2**n) [float("inf")] float("inf") float "inf" 2**n 2 n ans[0]=0 ans[0] ans 0 0 for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    tmp=0
    for j in c:
        tmp+=2**(j-1)
    na=ans.copy()
    for j in range(2**n):
        if ans[j|tmp]>na[j]+a:
            ans[j|tmp]=na[j]+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 tmp=0 tmp 0 for j in c:
        tmp+=2**(j-1)
     j c tmp+=2**(j-1) tmp 2**(j-1) 2 j-1 j 1 na=ans.copy() na ans.copy() ans.copy ans copy for j in range(2**n):
        if ans[j|tmp]>na[j]+a:
            ans[j|tmp]=na[j]+a j range(2**n) range 2**n 2 n if ans[j|tmp]>na[j]+a:
            ans[j|tmp]=na[j]+a ans[j|tmp]>na[j]+a ans[j|tmp] ans j|tmp j tmp na[j]+a na[j] na j a ans[j|tmp]=na[j]+a ans[j|tmp] ans j|tmp j tmp na[j]+a na[j] na j a if ans[2**n-1]==float("inf"):
    print(-1)
else:
    print(ans[2**n-1]) ans[2**n-1]==float("inf") ans[2**n-1] ans 2**n-1 2**n 2 n 1 float("inf") float "inf" print(-1) print -1 print(ans[2**n-1]) print ans[2**n-1] ans 2**n-1 2**n 2 n 1 na=ans.copy() ans.copy() na tmp=0 0 tmp m=map(int,input().split()) map(int,input().split()) m a,b=map(int,input().split()) map(int,input().split()) a n,m=map(int,input().split()) map(int,input().split()) n tmp+=2**(j-1) 2**(j-1) tmp ans=[float("inf")]*(2**n) [float("inf")]*(2**n) ans b=map(int,input().split()) map(int,input().split()) b c=list(map(int,input().split())) list(map(int,input().split())) c
n,m=map(int,input().split())
ans=[float("inf")]*(2**n)
ans[0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    tmp=0
    for j in c:
        tmp+=2**(j-1)
    na=ans.copy()
    for j in range(2**n):
        if ans[j|tmp]>na[j]+a:
            ans[j|tmp]=na[j]+a
if ans[2**n-1]==float("inf"):
    print(-1)
else:
    print(ans[2**n-1])