n,m=map(int,input().split())
up=float('inf')
dp=[[up]*(1<<n) for i in range(m)]
dp[0][0]=0
buy=[]
a=[]
for cnt in range(m):
    x,y=map(int,input().split())
    a.append(x)
    c=list(map(int,input().split()))
    tmp=0
    for w in c:
        tmp|=1<<(w-1)
    buy.append(tmp)
for i in range(m-1):
    for j in range(1<<n):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|buy[i]]=min(dp[i][j]+a[i],dp[i+1][j|buy[i]]) #i番目を買っているよ
if dp[m-1][-1]==float('inf'):
    print(-1)
else:
    print(dp[m-1][-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m up=float('inf') up float('inf') float 'inf' [up]*(1<<n) for i in range(m) for i in range(m) i range(m) range m for i in range(m) [up]*(1<<n) [up] up 1<<n 1 n dp=[[up]*(1<<n) for i in range(m)] dp [[up]*(1<<n) for i in range(m)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 buy=[] buy [] a=[] a [] for cnt in range(m):
    x,y=map(int,input().split())
    a.append(x)
    c=list(map(int,input().split()))
    tmp=0
    for w in c:
        tmp|=1<<(w-1)
    buy.append(tmp) cnt range(m) range m x,y=map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split y a.append(x) a.append a append x 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 w in c:
        tmp|=1<<(w-1)
     w c tmp|=1<<(w-1) tmp 1<<(w-1) 1 w-1 w 1 buy.append(tmp) buy.append buy append tmp for i in range(m-1):
    for j in range(1<<n):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|buy[i]]=min(dp[i][j]+a[i],dp[i+1][j|buy[i]]) #i番目を買っているよ i range(m-1) range m-1 m 1 for j in range(1<<n):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|buy[i]]=min(dp[i][j]+a[i],dp[i+1][j|buy[i]]) #i番目を買っているよ j range(1<<n) range 1<<n 1 n dp[i+1][j]=min(dp[i+1][j],dp[i][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i+1][j],dp[i][j]) min dp[i+1][j] [i+1] dp i+1 i 1 j dp[i][j] [i] dp i j dp[i+1][j|buy[i]]=min(dp[i][j]+a[i],dp[i+1][j|buy[i]]) dp[i+1][j|buy[i]] [i+1] dp i+1 i 1 j|buy[i] j buy[i] buy i min(dp[i][j]+a[i],dp[i+1][j|buy[i]]) min dp[i][j]+a[i] dp[i][j] [i] dp i j a[i] a i dp[i+1][j|buy[i]] [i+1] dp i+1 i 1 j|buy[i] j buy[i] buy i if dp[m-1][-1]==float('inf'):
    print(-1)
else:
    print(dp[m-1][-1]) dp[m-1][-1]==float('inf') dp[m-1][-1] [m-1] dp m-1 m 1 -1 float('inf') float 'inf' print(-1) print -1 print(dp[m-1][-1]) print dp[m-1][-1] [m-1] dp m-1 m 1 -1 y=map(int,input().split()) map(int,input().split()) y n,m=map(int,input().split()) map(int,input().split()) n a=[] [] a m=map(int,input().split()) map(int,input().split()) m dp=[[up]*(1<<n) for i in range(m)] [[up]*(1<<n) for i in range(m)] dp buy=[] [] buy tmp=0 0 tmp c=list(map(int,input().split())) list(map(int,input().split())) c tmp|=1<<(w-1) 1<<(w-1) tmp up=float('inf') float('inf') up x,y=map(int,input().split()) map(int,input().split()) x
n,m=map(int,input().split())
up=float('inf')
dp=[[up]*(1<<n) for i in range(m)]
dp[0][0]=0
buy=[]
a=[]
for cnt in range(m):
    x,y=map(int,input().split())
    a.append(x)
    c=list(map(int,input().split()))
    tmp=0
    for w in c:
        tmp|=1<<(w-1)
    buy.append(tmp)
for i in range(m-1):
    for j in range(1<<n):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|buy[i]]=min(dp[i][j]+a[i],dp[i+1][j|buy[i]]) #i番目を買っているよ
if dp[m-1][-1]==float('inf'):
    print(-1)
else:
    print(dp[m-1][-1])