Problem D

Statement
Copy Copied
Description:
This is an interactive problem.

Vladik has favorite game, in which he plays all his free time.

Game field could be represented as n × m matrix which consists of cells of three types:

- «.» — normal cell, player can visit it.
- «F» — finish cell, player has to finish his way there to win. There is exactly one cell of this type.
- «*» — dangerous cell, if player comes to this cell, he loses.

Initially player is located in the left top cell with coordinates (1, 1).

Player has access to 4 buttons "U", "D", "L", "R", each of them move player up, down, left and right directions respectively.

But it’s not that easy! Sometimes friends play game and change functions of buttons. Function of buttons "L" and "R" could have been swapped, also functions of buttons "U" and "D" could have been swapped. Note that functions of buttons can be changed only at the beginning of the game.

Help Vladik win the game!

Input Format:
First line contains two space-separated integers n and m (1 ≤ n, m ≤ 100) — number of rows and columns respectively.

Each of next n lines contains m characters describing corresponding row of field. Set of characters in field is described above.

Guaranteed that cell with coordinates (1, 1) is normal and there is at least one way from initial cell to finish cell without dangerous cells.

Output Format:
None

Note:
In first test case all four directions swapped with their opposite directions. Protocol of interaction In more convenient form:

This test could be presenter for hack in following way:

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
4615 go 0 2026-02-27T07:10:29.005543Z View View View Retry
4571 go 0 2026-02-25T08:24:03.525872Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
871 20260225-063403 gemini gemini-3.1-pro-preview go false 2026-02-25T07:06:30.728732Z View View View View Retry
475 20260217-144912 openrouter x-ai/grok-4 go false 2026-02-17T20:20:14.60555Z View View View View Retry