n, m = gets.split.map(&:to_i)

abc = []
m.times do 
    a, _ = gets.split
    c = gets.split.inject(0){|r, v| r | 1 << v.to_i - 1}
    abc << [a.to_i, c]
end

abc.sort_by!{|a, c| a}
r = 1 << n
dp = Array.new(r)
dp[0] = 0

abc.each do |a, c|
    (r - 1).downto(0) do |i|
        next if !dp[i]
        dp[i|c] = dp[i] + a if !dp[i|c] || dp[i|c] > dp[i] + a
    end
end

puts dp[-1] ? dp[-1] : -1