N, M = gets.chomp.split(" ").map(&:to_i)
K = []
I = Hash.new{|h, k| h[k] = Array.new}
M.times{|i|
  a, b = gets.chomp.split(" ").map(&:to_i)
  c = gets.chomp.split(" ").map(&:to_i)
  wk = 0
  K << [a, c.inject(0){|r, cc| r + (1 << (cc - 1))}]
  I[c.min] << i
}

INF = 10 ** 8
DP = Array.new(1 << N, INF)
DP[0] = 0
bef = [0]
(1..N).each{|n|
  nxt = []
  I[n].each{|i|
    bef.each{|b|
      prz, key = K[i]
      sum = DP[b] + prz
      kys = b | key
      DP[kys] = sum if DP[kys] > sum
      nxt << kys
    }
  }
  bef = nxt.uniq
}

puts DP[(1 << N) - 1] == INF ? -1 : DP[(1 << N) - 1]
