Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/robot-harakati

Robot movement

Easy 1000 ms 64 MB 22%
Share

A robot moves in four directions: s — north, j — south, q — east, g — west. The starting direction $c$ and a command $N$ are given: $0$ — keep moving (the direction does not change), $1$ — turn left by $90^{\circ}$, $2$ — turn right by $90^{\circ}$. Find the direction after the command.

Compass directions and the robot's turning angles

Input

One line with a direction letter $c$ and an integer $N$.

Output

One letter: the robot's new direction (s, j, q or g).

Note

$c$ is s, j, q or g
$N \in \{0, 1, 2\}$

Examples

Input #1
s 1
Output #1
g
Input #2
s 2
Output #2
q

Sign in to submit a solution

Signing up is free and takes a minute.