dp, valid and generate a section one at a time