while gets
	n, budget = $_.split.map(&:to_i)
	
	param = [[], [], []]
	n.times {
		gets
		c, v, d, l = gets.split.map(&:to_i)
		param[0] << [c, v]
		param[1] << [c, d]
		param[2] << [c, l]
	}

	p m = param.map{|a|
		table = (0..1).map{ Array.new(budget+1, 0) }
		for i in 0..a.size-1
			c, x = a[i]
			for j in 0..budget
				table[1][j] = 
					(0..j/c)
					.map{|k| table[0][j-k*c] + x * k}
					.max
			end
			table << table.shift
		end
	 	table[0].max
	}.max

end