INF = 10 ** 10
n, m = gets.split.map(&:to_i)
keys = []
m.times do
  open_cost = gets.to_i
  open_boxes = gets.split.map(&:to_i).inject(0) { |res, num| res | 2 ** (num - 1) }
  keys << [open_cost, open_boxes]
end
dp = Array.new(2 ** n, INF)
dp[0] = 0
keys.each do |open_cost, open_boxes|
  dp.each_with_index do |cost, opened|
    next if cost == INF
    next_opened = (opened | open_boxes)
    dp[next_opened] = cost + open_cost if dp[next_opened] > cost + open_cost
  end
end
puts dp.last == INF ? - 1 : dp.last