Setting the out of each quad to Top in the preprocess step
Minor change to the printing of the final result to remove trailing spaces