N,M=gets.chomp.split(" ").map(&:to_i)
keys = [] # [cost, key(bit), keys]
M.times do
    a,b=gets.chomp.split(" ").map(&:to_i)
    array=gets.chomp.split(" ").map(&:to_i)
    key = 0
    array.each do |i|
        key += 2**(i-1)
    end
    keys.push([a, key, array])
end
keys = keys.sort_by { |e| e[0] }

all_key = 0
keys.each do |e|
    all_key = all_key | e[1]
end
if all_key != (2**N)-1
    puts "-1"
    exit
end

INF = 10**6
dp = [INF]* 2**N
dp[0] = 0

keys.each do |a, key, array|
    dp.each_with_index do |price, index|
        new_key = key | index
        new_price = a + price
        if new_price < dp[new_key] 
            dp[new_key] = new_price
        end
    end
end
puts dp[-1]