N, M = gets.split.map(&:to_i)
Ikr = Hash.new{|h,k| h[k] = 100001 }
M.times{|i|
	a, c = gets.to_i, gets.split.map(&:to_i)
	kg = c.inject(0){|kg, tkr|
		kg | (1<<(tkr-1))
	}
	Ikr[kg] = [Ikr[kg], a].min
}
N.times{
	Ikr.keys.repeated_combination(2){|kg1, kg2|
		Ikr[kg1|kg2] = [Ikr[kg1|kg2], Ikr[kg1]+Ikr[kg2]].min
	}
}
p Ikr.fetch((1<<N)-1, -1)
