Merged horizontal and vertical loops