n,m=map(int,input().split())
dp=[]
INF=10**9
for i in range(m+1):
  dp.append([])
  dp[-1].append(0)
  for j in range(2**n-1):
    dp[-1].append(INF)
keys=[]
for i in range(m):
  a,b=map(int,input().split())
  r=['0']*n
  c=list(map(int,input().split()))
  for j in range(b):
    r[c[j]-1]='1'
  s=''.join(r)
  keys.append([int(s,2),a])
    
for i in range(m):
  for j in range(2**n):
    dp[i+1][j|keys[i][0]]=min(dp[i+1][j|keys[i][0]],dp[i][j]+keys[i][1])
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])
if dp[m][2**n-1]==10**9:
  print(-1)
else:
  print(dp[m][2**n-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m dp=[] dp [] INF=10**9 INF 10**9 10 9 for i in range(m+1):
  dp.append([])
  dp[-1].append(0)
  for j in range(2**n-1):
    dp[-1].append(INF) i range(m+1) range m+1 m 1 dp.append([]) dp.append dp append [] dp[-1].append(0) [-1].append [-1] dp -1 append 0 for j in range(2**n-1):
    dp[-1].append(INF) j range(2**n-1) range 2**n-1 2**n 2 n 1 dp[-1].append(INF) [-1].append [-1] dp -1 append INF keys=[] keys [] for i in range(m):
  a,b=map(int,input().split())
  r=['0']*n
  c=list(map(int,input().split()))
  for j in range(b):
    r[c[j]-1]='1'
  s=''.join(r)
  keys.append([int(s,2),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 r=['0']*n r ['0']*n ['0'] '0' n c=list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in range(b):
    r[c[j]-1]='1'
   j range(b) range b r[c[j]-1]='1' r[c[j]-1] r c[j]-1 c[j] c j 1 '1' s=''.join(r) s ''.join(r) ''.join '' join r keys.append([int(s,2),a]) keys.append keys append [int(s,2),a] int(s,2) int s 2 a for i in range(m):
  for j in range(2**n):
    dp[i+1][j|keys[i][0]]=min(dp[i+1][j|keys[i][0]],dp[i][j]+keys[i][1])
    dp[i+1][j]=min(dp[i+1][j],dp[i][j]) i range(m) range m for j in range(2**n):
    dp[i+1][j|keys[i][0]]=min(dp[i+1][j|keys[i][0]],dp[i][j]+keys[i][1])
    dp[i+1][j]=min(dp[i+1][j],dp[i][j]) j range(2**n) range 2**n 2 n dp[i+1][j|keys[i][0]]=min(dp[i+1][j|keys[i][0]],dp[i][j]+keys[i][1]) dp[i+1][j|keys[i][0]] [i+1] dp i+1 i 1 j|keys[i][0] j keys[i][0] [i] keys i 0 min(dp[i+1][j|keys[i][0]],dp[i][j]+keys[i][1]) min dp[i+1][j|keys[i][0]] [i+1] dp i+1 i 1 j|keys[i][0] j keys[i][0] [i] keys i 0 dp[i][j]+keys[i][1] dp[i][j] [i] dp i j keys[i][1] [i] keys i 1 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 if dp[m][2**n-1]==10**9:
  print(-1)
else:
  print(dp[m][2**n-1]) dp[m][2**n-1]==10**9 dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 10**9 10 9 print(-1) print -1 print(dp[m][2**n-1]) print dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 dp=[] [] dp a,b=map(int,input().split()) map(int,input().split()) a INF=10**9 10**9 INF c=list(map(int,input().split())) list(map(int,input().split())) c b=map(int,input().split()) map(int,input().split()) b r=['0']*n ['0']*n r n,m=map(int,input().split()) map(int,input().split()) n s=''.join(r) ''.join(r) s keys=[] [] keys m=map(int,input().split()) map(int,input().split()) m
n,m=map(int,input().split())
dp=[]
INF=10**9
for i in range(m+1):
  dp.append([])
  dp[-1].append(0)
  for j in range(2**n-1):
    dp[-1].append(INF)
keys=[]
for i in range(m):
  a,b=map(int,input().split())
  r=['0']*n
  c=list(map(int,input().split()))
  for j in range(b):
    r[c[j]-1]='1'
  s=''.join(r)
  keys.append([int(s,2),a])
    
for i in range(m):
  for j in range(2**n):
    dp[i+1][j|keys[i][0]]=min(dp[i+1][j|keys[i][0]],dp[i][j]+keys[i][1])
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])
if dp[m][2**n-1]==10**9:
  print(-1)
else:
  print(dp[m][2**n-1])