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