A number of prisoners are sent to a special prison. In this prison, they are all kept in solitary confinement and never have any contact with any other prisoner. There is an exercise yard where each day one prisoner, selected at random, is taken for one hour. In the exercise yard is a lever that has two positions, A and B.
Before they enter, one of the prisoners is selected at random and told that if he can say for certain that all the prisoners have been exercised at least once then they can all go free. He is only allowed to say this once and if he is wrong they will all stay there for life.
How does this prisoner know when to free himself and his fellow inmates?