Ilya's logical tests
The Ali-baba problem was offered at the Moscow Institute of Physics & Technology math olympiad (8th grade).
Ali-baba is standing in front of the treasure cave. By the entrance he finds a four-sectional rotating table, each section having a sign on it, either a plus or a minus. A sign becomes visible upon placing a hand on the section and can be flipped by will while the hand remains on it. Ali-baba may place his two hands on two sections of the table, see the signs and change none, one or both signs to their opposites, whichever he decides. After that, he must withdraw his hands. If at that point all four signs are the same, the cave with treasures will open. Otherwise, the table quickly rotates and then stops. Rotation is so fast that Ali-baba does not know the new positions of the sections relative to their old positions. Once the table stops, Ali-baba may repeat the whole process. It is known that the magic cave makes anyone trying to open it extremely unlucky. The old legend says that one needs not luck but wisdom to get all the signs to be the same. Help Ali-baba.