n, m = gets.chomp.split(' ').map(&:to_i)
keys = Array.new(m)
(0...m).each do |i|
  a, b = gets.chomp.split(' ').map(&:to_i)
  open = gets.chomp.split(' ').map(&:to_i)
  bit = 0
  (0...b).each do |j|
    bit += 1 << (open[j] - 1)
  end
  keys[i] = [a, bit]
end
dp = Array.new(1 << n, 1000000001)
dp[0] = 0
(0...m).each do |i|
  key = keys[i]
  (0...(1 << n)).each do |j|
    k = j | key[1]
    dp[k] = [dp[j] + key[0], dp[k]].min
  end
end
puts dp.last == 1000000001 ? '-1' : dp.last
