n, m  = gets.strip.split.map(&:to_i)
kk = m.times.map { [gets.strip.split.map(&:to_i).first, gets.strip.split.map(&:to_i).inject(0) {|m, e| m+2**(e-1) } ] }
INF = 10**10

dp = [INF] * (2**n)
dp[0] = 0

kk.each do |price, boxes|
  dp.each_with_index do |tmp_price, opened_boxes|
    current_opened = (opened_boxes | boxes)
    current_price = tmp_price + price
    dp[current_opened] = current_price if dp[current_opened] > current_price
  end
end

#p dp

if dp.last==INF
  p -1
else
  p dp.last
end
