INF = 1 << 28
def min(a,b); a < b ? a : b; end

N, M = gets.split.map(&:to_i)
K = M.times.map do 
  a,b = gets.split.map(&:to_i)
  keys = gets.split.map(&:to_i).inject(0){|s,i| s | (1 << (i - 1)) }  
  [a, keys]
end

dp = Array.new(1 << N, INF)
dp[0] = 0

K.each do |cost, keys|
  dp.each_index do |open|
    dp[open | keys] = min(dp[open] + cost, dp[open | keys])
  end
end
puts dp[-1] >= INF ? -1 : dp[-1]
