import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
keys = [None] * M
for i in range(M):
  cost,b = map(int,readline().split())
  bit = 0
  target = list(map(int,readline().split()))
  for t in target:
    bit += (1 << (t - 1))
  keys[i] = (cost, bit)
    
# 全ての鍵の組み合わせでDP
INF = 10 ** 8 + 1
dp = [INF for i in range(2 ** N)]
dp[0] = 0
for key in keys:
  cost, bit = key
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    if dp[j | bit] > dp[j] + cost:
      dp[j | bit] = dp[j] + cost

if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1]) import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline N,M = map(int,readline().split()) N map(int,readline().split()) map int readline().split() ().split () readline split M keys = [None] * M keys [None] * M [None] None M for i in range(M):
  cost,b = map(int,readline().split())
  bit = 0
  target = list(map(int,readline().split()))
  for t in target:
    bit += (1 << (t - 1))
  keys[i] = (cost, bit)
    
# 全ての鍵の組み合わせでDP i range(M) range M cost,b = map(int,readline().split()) cost map(int,readline().split()) map int readline().split() ().split () readline split b bit = 0 bit 0 target = list(map(int,readline().split())) target list(map(int,readline().split())) list map(int,readline().split()) map int readline().split() ().split () readline split for t in target:
    bit += (1 << (t - 1))
   t target bit += (1 << (t - 1)) bit 1 << (t - 1) 1 t - 1 t 1 keys[i] = (cost, bit) keys[i] keys i (cost, bit) cost bit INF = 10 ** 8 + 1 INF 10 ** 8 + 1 10 ** 8 10 8 1 INF 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) INF dp = [INF for i in range(2 ** N)] dp [INF for i in range(2 ** N)] dp[0] = 0 dp[0] dp 0 0 for key in keys:
  cost, bit = key
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    if dp[j | bit] > dp[j] + cost:
      dp[j | bit] = dp[j] + cost key keys cost, bit = key cost key bit for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    if dp[j | bit] > dp[j] + cost:
      dp[j | bit] = dp[j] + cost j range(len(dp) - 1, -1, -1) range len(dp) - 1 len(dp) len dp 1 -1 -1 if dp[j] == INF:
      continue
     dp[j] == INF dp[j] dp j INF continue if dp[j | bit] > dp[j] + cost:
      dp[j | bit] = dp[j] + cost dp[j | bit] > dp[j] + cost dp[j | bit] dp j | bit j bit dp[j] + cost dp[j] dp j cost dp[j | bit] = dp[j] + cost dp[j | bit] dp j | bit j bit dp[j] + cost dp[j] dp j cost 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 dp = [INF for i in range(2 ** N)] [INF for i in range(2 ** N)] dp bit = 0 0 bit bit += (1 << (t - 1)) 1 << (t - 1) bit keys = [None] * M [None] * M keys cost, bit = key key cost target = list(map(int,readline().split())) list(map(int,readline().split())) target M = map(int,readline().split()) map(int,readline().split()) M bit = key key bit b = map(int,readline().split()) map(int,readline().split()) b N,M = map(int,readline().split()) map(int,readline().split()) N cost,b = map(int,readline().split()) map(int,readline().split()) cost readline = sys.stdin.readline sys.stdin.readline readline INF = 10 ** 8 + 1 10 ** 8 + 1 INF
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
keys = [None] * M
for i in range(M):
  cost,b = map(int,readline().split())
  bit = 0
  target = list(map(int,readline().split()))
  for t in target:
    bit += (1 << (t - 1))
  keys[i] = (cost, bit)
    
# 全ての鍵の組み合わせでDP
INF = 10 ** 8 + 1
dp = [INF for i in range(2 ** N)]
dp[0] = 0
for key in keys:
  cost, bit = key
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    if dp[j | bit] > dp[j] + cost:
      dp[j | bit] = dp[j] + cost

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