SAM on instance segmentation

If you want to segment objects in a stack, Assuming you know the max amount of objects that can be stacked, can you segment using classes from top to bottom? (Item 1, item 2, item 3)?