LogiQuest

360. Robot Moves

EasySimulation

A robot starts at (0, 0) facing north. Commands: L turn left, R turn right, G move one step forward. Print its final position x y and facing direction (N, E, S or W).

Input format

A single line of commands.

Output format

x y direction

Example 1

Input

GGLLGG

Output

0 0 S

Example 2

Input

GL

Output

0 1 W

Constraints

1 ≤ length ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…