n, m = gets.to_s.split.map{|i| i.to_i }

bits = Array.new(n){|i| 2**i }
# p bits = Array.new(12){|i| 2**i } #=> [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
shops = Array.new(m) do
  a = gets.to_s.to_i
  c = gets.to_s.split.map{|i| i.to_i - 1 }
  bit = c.reduce(0){|s,t|bits[t]}
  [bit, a]
end.sort_by{|(bit, _)| bit }

inf = 10 ** 12
state_size = 2 ** n
d = Array.new(state_size, inf)
d[0] = 0

state_max = 0
shops.each do |(bit, a)|
  state_max |= bit
  state_max.times do |k|
    new = k | bit
    d[new] = d[k] + a if d[new] > d[k] + a
  end
  
end

puts d[-1] == inf ?  -1 : d[-1]