N,M = map(int,input().split())
COST = []
B = []
C = []
C_bit = []
INF = 10**18
dp = [INF]*(1<<N)
dp[0] = 0

for _ in range(M):
  a,b = map(int,input().split())
  C.append(list(map(int,input().split())))
  COST.append(a)
  B.append(b)

for i in range(M):
  bit = ['0']*N
  for j in range(B[i]):
    bit[C[i][j]-1] = '1'
  bit_int = int(''.join(bit),2)
  C_bit.append(bit_int)

for cost,c in zip(COST,C_bit):
  for i in range(1<<N):
    j = i|c
    d = dp[i]+cost
    if dp[j] > d:
      dp[j] = d

if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1]) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M COST = [] COST [] B = [] B [] C = [] C [] C_bit = [] C_bit [] INF = 10**18 INF 10**18 10 18 dp = [INF]*(1<<N) dp [INF]*(1<<N) [INF] INF 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for _ in range(M):
  a,b = map(int,input().split())
  C.append(list(map(int,input().split())))
  COST.append(a)
  B.append(b) _ range(M) range M a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b C.append(list(map(int,input().split()))) C.append C append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split COST.append(a) COST.append COST append a B.append(b) B.append B append b for i in range(M):
  bit = ['0']*N
  for j in range(B[i]):
    bit[C[i][j]-1] = '1'
  bit_int = int(''.join(bit),2)
  C_bit.append(bit_int) i range(M) range M bit = ['0']*N bit ['0']*N ['0'] '0' N for j in range(B[i]):
    bit[C[i][j]-1] = '1'
   j range(B[i]) range B[i] B i bit[C[i][j]-1] = '1' bit[C[i][j]-1] bit C[i][j]-1 C[i][j] [i] C i j 1 '1' bit_int = int(''.join(bit),2) bit_int int(''.join(bit),2) int ''.join(bit) ''.join '' join bit 2 C_bit.append(bit_int) C_bit.append C_bit append bit_int for cost,c in zip(COST,C_bit):
  for i in range(1<<N):
    j = i|c
    d = dp[i]+cost
    if dp[j] > d:
      dp[j] = d cost c zip(COST,C_bit) zip COST C_bit for i in range(1<<N):
    j = i|c
    d = dp[i]+cost
    if dp[j] > d:
      dp[j] = d i range(1<<N) range 1<<N 1 N j = i|c j i|c i c d = dp[i]+cost d dp[i]+cost dp[i] dp i cost if dp[j] > d:
      dp[j] = d dp[j] > d dp[j] dp j d dp[j] = d dp[j] dp j d if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1]) dp[-1] == INF dp[-1] dp -1 INF print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 bit_int = int(''.join(bit),2) int(''.join(bit),2) bit_int C_bit = [] [] C_bit M = map(int,input().split()) map(int,input().split()) M a,b = map(int,input().split()) map(int,input().split()) a COST = [] [] COST C = [] [] C N,M = map(int,input().split()) map(int,input().split()) N B = [] [] B INF = 10**18 10**18 INF b = map(int,input().split()) map(int,input().split()) b d = dp[i]+cost dp[i]+cost d j = i|c i|c j dp = [INF]*(1<<N) [INF]*(1<<N) dp bit = ['0']*N ['0']*N bit
N,M = map(int,input().split())
COST = []
B = []
C = []
C_bit = []
INF = 10**18
dp = [INF]*(1<<N)
dp[0] = 0

for _ in range(M):
  a,b = map(int,input().split())
  C.append(list(map(int,input().split())))
  COST.append(a)
  B.append(b)

for i in range(M):
  bit = ['0']*N
  for j in range(B[i]):
    bit[C[i][j]-1] = '1'
  bit_int = int(''.join(bit),2)
  C_bit.append(bit_int)

for cost,c in zip(COST,C_bit):
  for i in range(1<<N):
    j = i|c
    d = dp[i]+cost
    if dp[j] > d:
      dp[j] = d

if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1])