N, M = gets.split.map(&:to_i)
As, Cs = [], []
M.times do
  a, b = gets.split.map(&:to_i)
  As << a
  Cs << gets.split.map(&:to_i)
end
INF = 10**10

ds = Cs.map{|cs| cs.inject(0){|s, n| s | (1 << (n - 1))}}
dp = Array.new(M + 1){Array.new(1 << N, INF)}
dp[0][0] = 0
M.times do |i|
  (1 << N).times do |j|
    dp[i + 1][j] = dp[i][j] if dp[i + 1][j] > dp[i][j]
    dp[i + 1][j | ds[i]] = dp[i][j] + As[i] if dp[i + 1][j | ds[i]] > dp[i][j] + As[i]
  end
end
ans = dp[M][(1 << N) - 1]
puts ans == INF ? -1 : ans