#!/usr/bin/env python3
import sys
import random

already_fired = set()

def on_line(line: str):
    line = line.rstrip('\n')

    # If line starts with "GAME STARTED" then place ships
    if line.startswith("GAME STARTED"):
        print("PLACE B A1 N")
        print("PLACE B C1 N")

        print("PLACE C E1 N")

        print("PLACE D G1 N")
        print("PLACE D I1 N")

        print("PLACE P A7 D")
        print("PLACE P A9 D")
        print("PLACE P H8 N")

        print("READY")
        sys.stdout.flush()

    # If it's our turn, fire at a random position not fired before
    if line.startswith("YOUR TURN"):
        while True:
            row = random.randint(1, 10)
            row_char = chr(65 + row - 1)  # A-J
            column = random.randint(1, 10)
            pos = f"{row_char}{column}"

            if pos not in already_fired:
                break

        print(f"FIRE {pos}")
        sys.stdout.flush()
        already_fired.add(pos)

    # If game over, exit program
    if line.startswith("GAME OVER"):
        sys.exit(0)

def main():
    try:
        for line in sys.stdin:
            on_line(line)
    except KeyboardInterrupt:
        pass
    sys.exit(0)

if __name__ == "__main__":
    main()
