class Key
  attr_reader :a, :set

  def initialize(a, c)
    @a = a

    set = 0
    c.each do |num|
      num -= 1 # 0-index
      set |= 1 << num
    end
    @set = set
  end
end

INF = 1001001001

def get_everything(n, keys)
  dp = Array.new(1 << n, INF)
  dp[0] = 0

  (1 << n - 1).times do |i|
    keys.each do |key|
      t = i | key.set
      cost = dp[i] + key.a
      dp[t] = [dp[t], cost].min
    end
  end

  dp.last
end

n, m = gets.split.map(&:to_i)
keys = []
m.times do
  a, b = gets.split.map(&:to_i)
  c = gets.split.map(&:to_i)
  keys << Key.new(a, c)
end

puts get_everything(n, keys)
