n, m = map(int, input().split())
digit = ''.join(['0',str(n),'b'])
cost = [0] + [m*10**5+1] * (2**n-1)
for i in range(m):
  a, b = map(int,input().split())
  c = list(map(int, input().split()))
  cc = 0
  for j in c:
      cc += 2**(j-1)
  for j in range(2**n):
    jj = j | cc
    cost[jj] = min(cost[jj],cost[j]+a)
if cost[-1] == m*10**5+1:
  print(-1)
else:
  print(cost[-1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m digit = ''.join(['0',str(n),'b']) digit ''.join(['0',str(n),'b']) ''.join '' join ['0',str(n),'b'] '0' str(n) str n 'b' cost = [0] + [m*10**5+1] * (2**n-1) cost [0] + [m*10**5+1] * (2**n-1) [0] 0 [m*10**5+1] * (2**n-1) [m*10**5+1] m*10**5+1 m*10**5 m 10**5 10 5 1 2**n-1 2**n 2 n 1 for i in range(m):
  a, b = map(int,input().split())
  c = list(map(int, input().split()))
  cc = 0
  for j in c:
      cc += 2**(j-1)
  for j in range(2**n):
    jj = j | cc
    cost[jj] = min(cost[jj],cost[j]+a) 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 cc = 0 cc 0 for j in c:
      cc += 2**(j-1)
   j c cc += 2**(j-1) cc 2**(j-1) 2 j-1 j 1 for j in range(2**n):
    jj = j | cc
    cost[jj] = min(cost[jj],cost[j]+a) j range(2**n) range 2**n 2 n jj = j | cc jj j | cc j cc cost[jj] = min(cost[jj],cost[j]+a) cost[jj] cost jj min(cost[jj],cost[j]+a) min cost[jj] cost jj cost[j]+a cost[j] cost j a if cost[-1] == m*10**5+1:
  print(-1)
else:
  print(cost[-1]) cost[-1] == m*10**5+1 cost[-1] cost -1 m*10**5+1 m*10**5 m 10**5 10 5 1 print(-1) print -1 print(cost[-1]) print cost[-1] cost -1 m = map(int, input().split()) map(int, input().split()) m b = map(int,input().split()) map(int,input().split()) b c = list(map(int, input().split())) list(map(int, input().split())) c cc += 2**(j-1) 2**(j-1) cc digit = ''.join(['0',str(n),'b']) ''.join(['0',str(n),'b']) digit n, m = map(int, input().split()) map(int, input().split()) n cost = [0] + [m*10**5+1] * (2**n-1) [0] + [m*10**5+1] * (2**n-1) cost a, b = map(int,input().split()) map(int,input().split()) a cc = 0 0 cc jj = j | cc j | cc jj
n, m = map(int, input().split())
digit = ''.join(['0',str(n),'b'])
cost = [0] + [m*10**5+1] * (2**n-1)
for i in range(m):
  a, b = map(int,input().split())
  c = list(map(int, input().split()))
  cc = 0
  for j in c:
      cc += 2**(j-1)
  for j in range(2**n):
    jj = j | cc
    cost[jj] = min(cost[jj],cost[j]+a)
if cost[-1] == m*10**5+1:
  print(-1)
else:
  print(cost[-1])