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

ks = []
M.times.map do
  a,b = gets.split.map(&:to_i)
  c=0
  gets.split.each {|i| c += 1 << (i.to_i-1) }
  ks << [a,c]
end
ks.sort!

target = 2**N-1

idxs = [0]
arr = [0]
ks.each do |a,c|
  new = []
  idxs.each do |idx|
    t = arr[idx|c]
    if t.nil?
      new << (idx|c)
      arr[idx|c] = arr[idx]+a
    elsif arr[idx]+a < t
      arr[idx|c] = arr[idx]+a
    end
  end
  idxs += new
  # p [a,c,idxs,arr]
  if arr[target]
    puts arr[target]
    exit 0
  end
end

puts -1
