n, m = gets.chomp.split(' ').map(&:to_i)
max_ = 100000*n
dp = Array.new(2**n, max_)
dp[0] = 0

for i in 1..m do
  dp2 = Array.new(2**n, max_)
  cost, _ = gets.chomp.split(' ').map(&:to_i)
  cs = gets.chomp.split(' ').map(&:to_i)
  key = cs.map{|c| 1<<(c-1)}.inject(:+)
  for x in 0..((2**n)-1) do
    dp2[x] = [dp2[x], dp[x]].min
    dp2[x|key] = [dp2[x|key], dp[x] + cost].min
  end
  dp = dp2
end

if dp[2**n-1] == max_ then
  print -1
else
  print dp[2**n-1]
end


