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

prices = []
list = []

M.times do
  a, b = gets.split.map(&:to_i)
  keys = gets.split.map(&:to_i)

  v = 0

  keys.each do |k|
    v |= (1 << k - 1)
  end

  list << [a, v]
end

dp = Hash.new(Float::INFINITY)
dp[0] = 0

list.each do |price, ks|
  dp.keys.each do |old_list|
    current_list = old_list | ks
    k = dp[old_list] + price

    if k < dp[current_list]
      dp[current_list] = k
    end
  end
end

ans = dp[2 ** N - 1]

if ans == Float::INFINITY
  puts -1
else
  puts ans
end
