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