N, M = gets.chomp.split.map(&:to_i)

keys = []

M.times do |i|
  a, b = gets.chomp.split.map(&:to_i)
  cs = gets.chomp.split.map(&:to_i)
  keys << [a, cs]
end

dp = [987654321] * 2**N
dp[0] = 0

keys.each do |key|
  key_bit = 0 
  key[1].each do |c|
    key_bit += 2**(c - 1)
  end
  dp.size.times do |i|
    dp[i | key_bit] = [dp[i | key_bit], dp[i] + key[0]].min
  end
end

if dp[-1] == 987654321
  puts "-1"
else
  puts dp[-1]
end
