INF = 10**6


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

N = 1 << n 
keys = Array.new(N, INF)

m.times do
    a, b = gets.split.map(&:to_i)
    c = gets.split.map(&:to_i)

    num = 0
    c.each do |x|
        num += 1 << (x - 1)
    end

    keys[num] = a if keys[num] > a
end

keys[0] = 0
for x in 0...N
    for y in x+1...N
        if keys[x|y] > keys[x] + keys[y]
            keys[x|y] = keys[x] + keys[y]
        end
    end
end

if keys[N-1] == INF
    puts -1
else
    puts keys[N-1]
end