added box stacking and maximum length chain of pairs construction