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