N, M = gets.split.map(&:to_i)
Ikr = Hash.new{|h,k| h[k] = 100001 }
Q = []
M.times{|i|
	a, c = gets.to_i, gets.split.map(&:to_i)
	tkrbit = c.inject(0){|bit, tkr|
		bit | (1<<(tkr-1))
	}
	Q << ((a<<N)|tkrbit)
}
while lowest = Q.shift
	low_cost, low_tkrbit = lowest>>N, lowest&((1<<N)-1)
	next if Ikr[low_tkrbit] < low_cost
	if low_tkrbit == ((1<<N)-1)
		p low_cost
		exit
	end

	r = []
	while kg = Q.shift
		cost, tkrbit = kg>>N, kg&((1<<N)-1)
		next if Ikr[tkrbit] <= cost
		cost, tkrbit = cost+low_cost, tkrbit|low_tkrbit
		next if Ikr[tkrbit] <= cost

		Ikr[tkrbit] = cost
		r << ((cost<<N)|tkrbit)
	end

	Q.concat r
end
p -1
