n,m=map(int,input().split())
INF=10**10
dp=[[INF]*(1<<n) for _ in range(m+1)]
for i in range(m+1):
    dp[i][0]=0
a=[0]
key=[0]
for i in range(m):
    a0,b=map(int,input().split())
    a.append(a0)
    *c,=map(int,input().split())
    tmp=0
    for j in c:
        tmp+=1<<(j-1)
    key.append(tmp)

for i in range(1,m+1):
    for j in range(1<<n):
        if dp[i-1][j]<INF:
            dp[i][j]=min(dp[i][j],dp[i-1][j])
            dp[i][j|key[i]]=min(dp[i][j|key[i]],dp[i-1][j|key[i]],dp[i-1][j]+a[i])

ans=dp[-1][-1]
if ans!=INF:
    print(ans)
else:print(-1) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m INF=10**10 INF 10**10 10 10 [INF]*(1<<n) for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [INF]*(1<<n) [INF] INF 1<<n 1 n dp=[[INF]*(1<<n) for _ in range(m+1)] dp [[INF]*(1<<n) for _ in range(m+1)] for i in range(m+1):
    dp[i][0]=0 i range(m+1) range m+1 m 1 dp[i][0]=0 dp[i][0] [i] dp i 0 0 a=[0] a [0] 0 key=[0] key [0] 0 for i in range(m):
    a0,b=map(int,input().split())
    a.append(a0)
    *c,=map(int,input().split())
    tmp=0
    for j in c:
        tmp+=1<<(j-1)
    key.append(tmp) i range(m) range m a0,b=map(int,input().split()) a0 map(int,input().split()) map int input().split() ().split () input split b a.append(a0) a.append a append a0 *c,=map(int,input().split()) *c c map(int,input().split()) map int input().split() ().split () input split tmp=0 tmp 0 for j in c:
        tmp+=1<<(j-1)
     j c tmp+=1<<(j-1) tmp 1<<(j-1) 1 j-1 j 1 key.append(tmp) key.append key append tmp for i in range(1,m+1):
    for j in range(1<<n):
        if dp[i-1][j]<INF:
            dp[i][j]=min(dp[i][j],dp[i-1][j])
            dp[i][j|key[i]]=min(dp[i][j|key[i]],dp[i-1][j|key[i]],dp[i-1][j]+a[i]) i range(1,m+1) range 1 m+1 m 1 for j in range(1<<n):
        if dp[i-1][j]<INF:
            dp[i][j]=min(dp[i][j],dp[i-1][j])
            dp[i][j|key[i]]=min(dp[i][j|key[i]],dp[i-1][j|key[i]],dp[i-1][j]+a[i]) j range(1<<n) range 1<<n 1 n if dp[i-1][j]<INF:
            dp[i][j]=min(dp[i][j],dp[i-1][j])
            dp[i][j|key[i]]=min(dp[i][j|key[i]],dp[i-1][j|key[i]],dp[i-1][j]+a[i]) dp[i-1][j]<INF dp[i-1][j] [i-1] dp i-1 i 1 j INF dp[i][j]=min(dp[i][j],dp[i-1][j]) dp[i][j] [i] dp i j min(dp[i][j],dp[i-1][j]) min dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j|key[i]]=min(dp[i][j|key[i]],dp[i-1][j|key[i]],dp[i-1][j]+a[i]) dp[i][j|key[i]] [i] dp i j|key[i] j key[i] key i min(dp[i][j|key[i]],dp[i-1][j|key[i]],dp[i-1][j]+a[i]) min dp[i][j|key[i]] [i] dp i j|key[i] j key[i] key i dp[i-1][j|key[i]] [i-1] dp i-1 i 1 j|key[i] j key[i] key i dp[i-1][j]+a[i] dp[i-1][j] [i-1] dp i-1 i 1 j a[i] a i ans=dp[-1][-1] ans dp[-1][-1] [-1] dp -1 -1 if ans!=INF:
    print(ans)
else:print(-1) ans!=INF ans INF print(ans) print ans a0,b=map(int,input().split()) map(int,input().split()) a0 ans=dp[-1][-1] dp[-1][-1] ans b=map(int,input().split()) map(int,input().split()) b a=[0] [0] a m=map(int,input().split()) map(int,input().split()) m key=[0] [0] key INF=10**10 10**10 INF n,m=map(int,input().split()) map(int,input().split()) n tmp=0 0 tmp dp=[[INF]*(1<<n) for _ in range(m+1)] [[INF]*(1<<n) for _ in range(m+1)] dp tmp+=1<<(j-1) 1<<(j-1) tmp
n,m=map(int,input().split())
INF=10**10
dp=[[INF]*(1<<n) for _ in range(m+1)]
for i in range(m+1):
    dp[i][0]=0
a=[0]
key=[0]
for i in range(m):
    a0,b=map(int,input().split())
    a.append(a0)
    *c,=map(int,input().split())
    tmp=0
    for j in c:
        tmp+=1<<(j-1)
    key.append(tmp)

for i in range(1,m+1):
    for j in range(1<<n):
        if dp[i-1][j]<INF:
            dp[i][j]=min(dp[i][j],dp[i-1][j])
            dp[i][j|key[i]]=min(dp[i][j|key[i]],dp[i-1][j|key[i]],dp[i-1][j]+a[i])

ans=dp[-1][-1]
if ans!=INF:
    print(ans)
else:print(-1)
