n,m=map(int,input().split())
g=(1<<n)
dp=[10**18]*g
dp[0]=0
for i in  range(m):
    a,s=map(int,input().split())
    f=0
    for k in map(int,input().split()):
        f+=1<<(k-1)
    for j in range(g-1,-1,-1):
        dp[j|f]=min(dp[j]+a,dp[j|f])
print(-1 if dp[-1]==10**18 else dp[-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m g=(1<<n) g 1<<n 1 n dp=[10**18]*g dp [10**18]*g [10**18] 10**18 10 18 g dp[0]=0 dp[0] dp 0 0 for i in  range(m):
    a,s=map(int,input().split())
    f=0
    for k in map(int,input().split()):
        f+=1<<(k-1)
    for j in range(g-1,-1,-1):
        dp[j|f]=min(dp[j]+a,dp[j|f]) i range(m) range m a,s=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split s f=0 f 0 for k in map(int,input().split()):
        f+=1<<(k-1)
     k map(int,input().split()) map int input().split() ().split () input split f+=1<<(k-1) f 1<<(k-1) 1 k-1 k 1 for j in range(g-1,-1,-1):
        dp[j|f]=min(dp[j]+a,dp[j|f]) j range(g-1,-1,-1) range g-1 g 1 -1 -1 dp[j|f]=min(dp[j]+a,dp[j|f]) dp[j|f] dp j|f j f min(dp[j]+a,dp[j|f]) min dp[j]+a dp[j] dp j a dp[j|f] dp j|f j f print(-1 if dp[-1]==10**18 else dp[-1]) print -1 if dp[-1]==10**18 else dp[-1] dp[-1]==10**18 dp[-1] dp -1 10**18 10 18 -1 dp[-1] dp -1 n,m=map(int,input().split()) map(int,input().split()) n s=map(int,input().split()) map(int,input().split()) s f+=1<<(k-1) 1<<(k-1) f a,s=map(int,input().split()) map(int,input().split()) a m=map(int,input().split()) map(int,input().split()) m dp=[10**18]*g [10**18]*g dp f=0 0 f g=(1<<n) 1<<n g
n,m=map(int,input().split())
g=(1<<n)
dp=[10**18]*g
dp[0]=0
for i in  range(m):
    a,s=map(int,input().split())
    f=0
    for k in map(int,input().split()):
        f+=1<<(k-1)
    for j in range(g-1,-1,-1):
        dp[j|f]=min(dp[j]+a,dp[j|f])
print(-1 if dp[-1]==10**18 else dp[-1])