n,m=map(int,input().split())
a,c=[],[]
for _ in range(m):
  a.append(list(map(int,input().split()))[0])
  bit=0
  for i in input().split():
    bit|=(1<<(int(i)-1))
  c.append(bit)
inf=float("inf")
dp=[[inf]*(1<<n) for i in range(m+1)]
dp[0][0]=0
for i in range(m):
  for j in range(1<<n):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])
    next_bit=j|c[i]
    dp[i+1][next_bit]=min(dp[i+1][next_bit],dp[i][j]+a[i])
print(dp[-1][-1] if dp[-1][-1]!=inf else -1) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a,c=[],[] a [] c [] for _ in range(m):
  a.append(list(map(int,input().split()))[0])
  bit=0
  for i in input().split():
    bit|=(1<<(int(i)-1))
  c.append(bit) _ range(m) range m a.append(list(map(int,input().split()))[0]) a.append a append list(map(int,input().split()))[0] (map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 0 bit=0 bit 0 for i in input().split():
    bit|=(1<<(int(i)-1))
   i input().split() ().split () input split bit|=(1<<(int(i)-1)) bit 1<<(int(i)-1) 1 int(i)-1 int(i) int i 1 c.append(bit) c.append c append bit inf=float("inf") inf float("inf") float "inf" [inf]*(1<<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) [inf]*(1<<n) [inf] inf 1<<n 1 n dp=[[inf]*(1<<n) for i in range(m+1)] dp [[inf]*(1<<n) for i in range(m+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(m):
  for j in range(1<<n):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])
    next_bit=j|c[i]
    dp[i+1][next_bit]=min(dp[i+1][next_bit],dp[i][j]+a[i]) i range(m) range m for j in range(1<<n):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])
    next_bit=j|c[i]
    dp[i+1][next_bit]=min(dp[i+1][next_bit],dp[i][j]+a[i]) j range(1<<n) range 1<<n 1 n 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 next_bit=j|c[i] next_bit j|c[i] j c[i] c i dp[i+1][next_bit]=min(dp[i+1][next_bit],dp[i][j]+a[i]) dp[i+1][next_bit] [i+1] dp i+1 i 1 next_bit min(dp[i+1][next_bit],dp[i][j]+a[i]) min dp[i+1][next_bit] [i+1] dp i+1 i 1 next_bit dp[i][j]+a[i] dp[i][j] [i] dp i j a[i] a i print(dp[-1][-1] if dp[-1][-1]!=inf else -1) print dp[-1][-1] if dp[-1][-1]!=inf else -1 dp[-1][-1]!=inf dp[-1][-1] [-1] dp -1 -1 inf dp[-1][-1] [-1] dp -1 -1 -1 bit|=(1<<(int(i)-1)) 1<<(int(i)-1) bit bit=0 0 bit m=map(int,input().split()) map(int,input().split()) m inf=float("inf") float("inf") inf next_bit=j|c[i] j|c[i] next_bit dp=[[inf]*(1<<n) for i in range(m+1)] [[inf]*(1<<n) for i in range(m+1)] dp a,c=[],[] [] a n,m=map(int,input().split()) map(int,input().split()) n c=[],[] [] c
n,m=map(int,input().split())
a,c=[],[]
for _ in range(m):
  a.append(list(map(int,input().split()))[0])
  bit=0
  for i in input().split():
    bit|=(1<<(int(i)-1))
  c.append(bit)
inf=float("inf")
dp=[[inf]*(1<<n) for i in range(m+1)]
dp[0][0]=0
for i in range(m):
  for j in range(1<<n):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])
    next_bit=j|c[i]
    dp[i+1][next_bit]=min(dp[i+1][next_bit],dp[i][j]+a[i])
print(dp[-1][-1] if dp[-1][-1]!=inf else -1)