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