Under construction

Still being built. Things may change

Headshot

Interview

Time limit1sMemory limit128 MB

Summary
Given a circular string of loaded/empty chambers, decide whether shooting immediately or re-spinning gives a lower chance of firing given the previous chamber was empty.
Level

Medium4 of 10

Topics
String, Probability, Math
Solved
No attempts yet

Problem

You have a revolver whose cylinder has nn chambers arranged in a circle. Each chamber is either empty or holds one round. One chamber is aligned with the barrel. When the trigger is pulled, the cylinder rotates so that the next chamber becomes aligned with the barrel, and the hammer strikes it: if that chamber holds a round, a shot is fired through the barrel; if it is empty, there is no shot but just a "click".

You are playing Russian roulette with a friend. Your friend loads rounds into some of the chambers, spins the cylinder to a uniformly random position, points the gun at their own head, and pulls the trigger. You hear a "click" and nothing else — the struck chamber was empty, so the gun did not fire.

Now it is your turn to point the gun at your head and pull the trigger. You have two options:

  • Pull the trigger right away.
  • Spin the cylinder to a uniformly random position first, then pull the trigger.

Which option gives you the greater chance of survival?

Input

The input consists of a single line containing a string of nn digits "0" and "1" (2≤n≤1002 \le n \le 100). The string describes how the chambers are loaded: "0" is an empty chamber and "1" is a loaded one. When the cylinder rotates before a shot, the chamber immediately to the right of the current one becomes aligned with the barrel. Because the chambers lie on a circle, the first chamber of the string follows the last one. The string contains at least one "0".

Output

Print exactly one of the following words:

  • SHOOT — if pulling the trigger right away makes you less likely to be shot (more likely that the struck chamber is empty).
  • ROTATE — if spinning the cylinder to a random position before pulling the trigger makes you less likely to be shot.
  • EQUAL — if the two options give the same probability of being shot.

Examples3

  1. Example 1

    Input
    0011
    
    Expected output
    EQUAL
    
  2. Example 2

    Input
    0111
    
    Expected output
    ROTATE
    
  3. Example 3

    Input
    000111
    
    Expected output
    SHOOT