n,m=map(int,input().split())
a=[0]*m
b=[0]*m
c=[[] for i in range(m)]
for i in range(m):
  a[i],b[i] =map(int,input().split())
  c[i] = sum([2**(int(x)-1) for x in input().split()])
# N
dp = [1000000000 for i in range(2**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])
if dp[2**n-1]==1000000000:
  print(-1)
else:
  print(dp[2**n-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a=[0]*m a [0]*m [0] 0 m b=[0]*m b [0]*m [0] 0 m [] for i in range(m) for i in range(m) i range(m) range m for i in range(m) [] c=[[] for i in range(m)] c [[] for i in range(m)] for i in range(m):
  a[i],b[i] =map(int,input().split())
  c[i] = sum([2**(int(x)-1) for x in input().split()])
# N i range(m) range m a[i],b[i] =map(int,input().split()) a[i] a i map(int,input().split()) map int input().split() ().split () input split b[i] b i 2**(int(x)-1) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() 2**(int(x)-1) 2 int(x)-1 int(x) int x 1 c[i] = sum([2**(int(x)-1) for x in input().split()]) c[i] c i sum([2**(int(x)-1) for x in input().split()]) sum [2**(int(x)-1) for x in input().split()] 1000000000 for i in range(2**n) for i in range(2**n) i range(2**n) range 2**n 2 n for i in range(2**n) 1000000000 dp = [1000000000 for i in range(2**n)] dp [1000000000 for i in range(2**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 if dp[2**n-1]==1000000000:
  print(-1)
else:
  print(dp[2**n-1]) dp[2**n-1]==1000000000 dp[2**n-1] dp 2**n-1 2**n 2 n 1 1000000000 print(-1) print -1 print(dp[2**n-1]) print dp[2**n-1] dp 2**n-1 2**n 2 n 1 b=[0]*m [0]*m b a=[0]*m [0]*m a m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n c=[[] for i in range(m)] [[] for i in range(m)] c dp = [1000000000 for i in range(2**n)] [1000000000 for i in range(2**n)] dp
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
c=[[] for i in range(m)]
for i in range(m):
  a[i],b[i] =map(int,input().split())
  c[i] = sum([2**(int(x)-1) for x in input().split()])
# N
dp = [1000000000 for i in range(2**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])
if dp[2**n-1]==1000000000:
  print(-1)
else:
  print(dp[2**n-1])
