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

