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