Think about how you will get back to the box you got assigned to. Like what do you have to see in order to return to box 89, where you started?
This ordering then partitions the boxes into cycles where each prisoner is in their cycle, and has a low chance of having 50-sized cycles.
Still mesmerized at how the choice of query can improve your chances like that without accumulating information.