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

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

target = 2**N-1

idxs = [0]
arr = [0]
ks.each do |a,c|
  idxs.length.times do |i|
    idx = idxs[i]
    t = arr[idx|c]
    if t.nil?
      idxs << (idx|c)
      arr[idx|c] = arr[idx]+a
    elsif arr[idx]+a < t
      arr[idx|c] = arr[idx]+a
    end
  end
end

if arr[target]
  puts arr[target]
else
  puts -1
end
