Set Viewport without intersect each other into sheet

Hi all,
how to set viewport using Viewport.LableOutline (rhythm) node into Sheet as per coordinates ( By manual input using ) and also compare vertical and horizontal remaining space for next placement.
For better understanding please go through attached snip.

Thank You in advance,
Much appreciated

Hello everyone,
Is it possible to make this script?
If anyone have any suggestion please share with me.

Thank You