#!/usr/bin/env python3 import collections import sys MAX_SIZE = 20 DIST_INF = 100 DRS = [1, 0, -1, 0] DCS = [0, 1, 0, -1] class Solver(object): def __init__(self): self.visited = collections.defaultdict(bool) def depth_first_search(self, r0, c0, angle): self.visited[(r0, c0)] = True for _ in range(4): result = self.submit("R") while result >= DIST_INF: self.submit("F") angle = (angle + 1) % 4 r = r0 + DRS[angle] c = c0 + DCS[angle] if result > 0 and not self.visited[(r, c)]: self.submit("F") self.depth_first_search(r, c, angle) self.submit("B") @staticmethod def submit(command): print(command) sys.stdout.flush() result = input() if result.startswith("M"): sys.exit() else: return int(result) def main(): s = Solver() _ = input() s.depth_first_search(0, 0, 1) if __name__ == '__main__': main()