n, m = map(int, input().split())
price = [0] * m
treasure = [0] * m
for i in range(m):
  price[i], _ = map(int, input().split())
  for c in map(int, input().split()):
    treasure[i] += 1 << c-1
dp = [10 ** 8 + 1] * (1 << n)
dp[0] = 0
for bit in range((1 << n) - 1):
  cost = dp[bit]
  for i in range(m):
    next_bit = treasure[i] | bit
    next_cost = price[i] + cost
    dp[next_bit] = min(dp[next_bit], next_cost)
if dp[-1] > 10 ** 8:
  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 price = [0] * m price [0] * m [0] 0 m treasure = [0] * m treasure [0] * m [0] 0 m for i in range(m):
  price[i], _ = map(int, input().split())
  for c in map(int, input().split()):
    treasure[i] += 1 << c-1 i range(m) range m price[i], _ = map(int, input().split()) price[i] price i map(int, input().split()) map int input().split() ().split () input split _ for c in map(int, input().split()):
    treasure[i] += 1 << c-1 c map(int, input().split()) map int input().split() ().split () input split treasure[i] += 1 << c-1 treasure[i] treasure i 1 << c-1 1 c-1 c 1 dp = [10 ** 8 + 1] * (1 << n) dp [10 ** 8 + 1] * (1 << n) [10 ** 8 + 1] 10 ** 8 + 1 10 ** 8 10 8 1 1 << n 1 n dp[0] = 0 dp[0] dp 0 0 for bit in range((1 << n) - 1):
  cost = dp[bit]
  for i in range(m):
    next_bit = treasure[i] | bit
    next_cost = price[i] + cost
    dp[next_bit] = min(dp[next_bit], next_cost) bit range((1 << n) - 1) range (1 << n) - 1 1 << n 1 n 1 cost = dp[bit] cost dp[bit] dp bit for i in range(m):
    next_bit = treasure[i] | bit
    next_cost = price[i] + cost
    dp[next_bit] = min(dp[next_bit], next_cost) i range(m) range m next_bit = treasure[i] | bit next_bit treasure[i] | bit treasure[i] treasure i bit next_cost = price[i] + cost next_cost price[i] + cost price[i] price i cost dp[next_bit] = min(dp[next_bit], next_cost) dp[next_bit] dp next_bit min(dp[next_bit], next_cost) min dp[next_bit] dp next_bit next_cost if dp[-1] > 10 ** 8:
  print(-1)
else:
  print(dp[-1]) dp[-1] > 10 ** 8 dp[-1] dp -1 10 ** 8 10 8 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 m = map(int, input().split()) map(int, input().split()) m cost = dp[bit] dp[bit] cost next_bit = treasure[i] | bit treasure[i] | bit next_bit treasure = [0] * m [0] * m treasure dp = [10 ** 8 + 1] * (1 << n) [10 ** 8 + 1] * (1 << n) dp price = [0] * m [0] * m price next_cost = price[i] + cost price[i] + cost next_cost _ = map(int, input().split()) map(int, input().split()) _ n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
price = [0] * m
treasure = [0] * m
for i in range(m):
  price[i], _ = map(int, input().split())
  for c in map(int, input().split()):
    treasure[i] += 1 << c-1
dp = [10 ** 8 + 1] * (1 << n)
dp[0] = 0
for bit in range((1 << n) - 1):
  cost = dp[bit]
  for i in range(m):
    next_bit = treasure[i] | bit
    next_cost = price[i] + cost
    dp[next_bit] = min(dp[next_bit], next_cost)
if dp[-1] > 10 ** 8:
  print(-1)
else:
  print(dp[-1])