TTC '18 Contest 2 P2 - Forward and Turn
View as PDF is playing with a toy tank. He places it on a grid, the initial location of the tank being .
Then, he gives the tank a series of instructions , consisting of two kinds of letters, executed in order from front to back:
F: Move in the current direction by distance 1.T: Turn 90 degrees clockwise.
has a simple question for you to answer: At what position will the tank stop at?
The tank will start facing up (if the instruction were F, the next position would be ).
Input Specification
The first line will contain
, the number of instructions 's tank will have.
The second line of input will contain two space separated integers and
, the initial position of the tank.
The last line of input will contain a string , consisting of only
F and T as characters.
Output Specification
The one and only line of output will contain 2 space-separated integers, and
, the ending position of the tank.
Sample Input 1
5
0 0
FFTFT
Sample Output 1
1 2
Sample Input 2
5
1 1
FFTFT
Sample Output 2
2 3
Comments