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

abc = []
m.times do 
    a, _ = gets.split
    c = gets.split.map(&:to_i)
    abc << [a.to_i, c]
end

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

abc.each do |a, c|
    c = c.inject(0){|r, v| r | 1 << v - 1}
    (r - 1).downto(0) do |i|
        dp[i | c] = dp[i] + a if dp[i | c] > dp[i] + a
    end
end

puts dp[-1] == 1 << 40 ? -1 : dp[-1]