N,M = gets.split.map(&:to_i)
keys = Array.new(M)
i = 0
while i < M
  a,_ = gets.split.map(&:to_i)
  n = 0
  gets.split.each do |c|
    n |= 1 << c.to_i-1
  end
  keys[i] = [a,n]
  i += 1
end

dp = Array.new(5000, 1e9)
dp[0] = 0

keys.each do |price,now|
  bits = 0
  while bits < (1<<N)
    n = dp[bits] + price
    if n < dp[bits|now]
      dp[bits|now] = n
    end
    bits += 1
  end
end

if dp[(1<<N)-1] == 1e9
  p -1
else
  p dp[(1<<N)-1]
end
