N,M=gets.split.map(&:to_i)

idxs = [0]
arr = [0]
M.times do
  a = gets.to_i
  c = gets.split.inject(0) {|n,i| n + (1 << (i.to_i-1)) }

  idxs.length.times do |i|
    idx = idxs[i]
    n = arr[idx|c]
    if n.nil?
      idxs << (idx|c)
      arr[idx|c] = arr[idx]+a
    elsif arr[idx]+a < n
      arr[idx|c] = arr[idx]+a
    end
  end
end

puts(arr[2**N-1]||-1)
