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]

h = { 0 => 0 }
m.times do |i|
  
  a, b = gets.to_s.split.map{|i| i.to_i     }
  c    = gets.to_s.split.map{|i| i.to_i - 1 }
  
  bit = c.map{|t| bits[t] }.reduce(0){|s,t|s+t}
  
  h.keys.each do |k|
    
    new = k | bit
    h[new] = h[k] + a if ( !h.has_key?(new) ||  h[new] > h[k] + a )
    
  end
  
end

puts h[ (1 << n) - 1] || -1