n,m=map(int,input().split())
key=[]
for _ in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  bi=0
  for i in c:
    bi+=1<<(i-1)
  key.append([a,bi])
#print(key)

INF=2**24
dp=[INF]*(1<<n)
dp[0]=0
for k in key:
  for b in range(1<<n):
    dp[b|k[1]]=min(dp[b|k[1]],dp[b]+k[0])
    #print(b,k[1],b|k[1],dp)
    
print(-1 if dp[-1]==INF else dp[-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m key=[] key [] for _ in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  bi=0
  for i in c:
    bi+=1<<(i-1)
  key.append([a,bi])
#print(key) _ 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 bi=0 bi 0 for i in c:
    bi+=1<<(i-1)
   i c bi+=1<<(i-1) bi 1<<(i-1) 1 i-1 i 1 key.append([a,bi]) key.append key append [a,bi] a bi INF=2**24 INF 2**24 2 24 dp=[INF]*(1<<n) dp [INF]*(1<<n) [INF] INF 1<<n 1 n dp[0]=0 dp[0] dp 0 0 for k in key:
  for b in range(1<<n):
    dp[b|k[1]]=min(dp[b|k[1]],dp[b]+k[0])
    #print(b,k[1],b|k[1],dp)
     k key for b in range(1<<n):
    dp[b|k[1]]=min(dp[b|k[1]],dp[b]+k[0])
    #print(b,k[1],b|k[1],dp)
     b range(1<<n) range 1<<n 1 n dp[b|k[1]]=min(dp[b|k[1]],dp[b]+k[0]) dp[b|k[1]] dp b|k[1] b k[1] k 1 min(dp[b|k[1]],dp[b]+k[0]) min dp[b|k[1]] dp b|k[1] b k[1] k 1 dp[b]+k[0] dp[b] dp b k[0] k 0 print(-1 if dp[-1]==INF else dp[-1]) print -1 if dp[-1]==INF else dp[-1] dp[-1]==INF dp[-1] dp -1 INF -1 dp[-1] dp -1 n,m=map(int,input().split()) map(int,input().split()) n dp=[INF]*(1<<n) [INF]*(1<<n) dp INF=2**24 2**24 INF b=map(int,input().split()) map(int,input().split()) b m=map(int,input().split()) map(int,input().split()) m a,b=map(int,input().split()) map(int,input().split()) a c=list(map(int,input().split())) list(map(int,input().split())) c bi=0 0 bi bi+=1<<(i-1) 1<<(i-1) bi key=[] [] key
n,m=map(int,input().split())
key=[]
for _ in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  bi=0
  for i in c:
    bi+=1<<(i-1)
  key.append([a,bi])
#print(key)

INF=2**24
dp=[INF]*(1<<n)
dp[0]=0
for k in key:
  for b in range(1<<n):
    dp[b|k[1]]=min(dp[b|k[1]],dp[b]+k[0])
    #print(b,k[1],b|k[1],dp)
    
print(-1 if dp[-1]==INF else dp[-1])