Warehouse Robot

Contest 3

An automated warehouse uses a grid-based floor plan to guide delivery robots. The robot starts at the top-left corner (row , column ) and receives a sequence of move commands. Each cell is either open (.) or blocked by a shelf (#).

The robot processes each command in order:
- R: move one cell right (column )
- L: move one cell left (column )
- D: move one cell down (row )
- U: move one cell up (row )

If a move would take the robot off the grid or into a shelf (#), the robot ignores that command and stays in place.

After processing all commands, output the robot's final position and how many commands were successfully executed (not ignored).

Input:
- Line 1: two integers and , the number of rows and columns
- Next lines: the grid, each line containing characters (. or #)
- Last line: a string of move commands (R, L, D, U)

Output:
- Line 1: two integers, the final row and column (-indexed), separated by a space
- Line 2: the number of successfully executed commands
Constraints
. The top-left cell is always open. The command string is to characters.
Sample input
3 4
....
.#..
....
RRDDLLD
Sample output
2 0
6
Stdin