Key = Struct.new(:price, :chests)

n, m = gets.split(' ').map(&:to_i)
keys = m.times.map {
  price, _ = gets.split(' ').map(&:to_i)
  Key.new(price, gets.split(' ').map(&:to_i))
}

class Array
  def off(index)
    slice(0, index).push(*slice((index + 1)...-1))
  end
end

def solve(remained_keys, open_chests, spent_money)
  return spent_money if open_chests.empty?

  useful_keys = remained_keys.reject { |key| (key.chests & open_chests).empty? }
  return Float::INFINITY if useful_keys.empty?

  useful_keys.map.with_index { |key, index|
    solve(useful_keys.off(index), open_chests - key.chests, spent_money + key.price)
  }.min
end

spent_money = solve(keys, [*1..n], 0)

if spent_money == Float::INFINITY
  puts -1
else
  puts spent_money
end
