n, m = gets.split.map(&:to_i)
done = 2 ** n - 1
min_of = [0] + [nil] * done

key_vals = m.times.map{|i|
    price, count = gets.split.map(&:to_i)
    val = gets.split.map(&:to_i).inject(0){|acc, it| acc + 2 ** (it - 1)}
    min_of[val] = price
    val
}

(1...done).each{|a|
    next if nil == min_of[a]
    (1...done).each{|b|
        next if nil == min_of[b]
        cost = min_of[a] + min_of[b]
        val = a | b
        if min_of[val] == nil || min_of[val] > cost
            min_of[val] = cost
        end
    }    
}

if min_of[done] == nil
    puts -1
else
    puts min_of[done]
end