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

bin = Array.new(n+2)
bin[1] = 1
2.upto(n+1) {|i| bin[i] = bin[i-1] * 2}

dp = Array.new(bin[n+1],-1)

m.times do 
    a,_ = gets.split.map!(&:to_i)
    c = 0
    gets.split.each {|e| c += bin[e.to_i]}

    x = dp.dup
    x.each_with_index do |e,i|
        next if e == -1
        z = i | c
        dp[z] = e + a if (dp[z] == -1 || dp[z] > e + a)
    end

    dp[c] = a if dp[c] == -1 || dp[c] > a
    #p dp
end

puts dp.last