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

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

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

ret = arr[2**N-1] || -1
puts ret
