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

~/algor $ cat problems/case-robot-qadami

Robot steps

Easy 1000 ms 64 MB 23%
Share

A robot stands at the point $(x; y)$ of the coordinate plane and walks $n$ steps in direction $c$. Directions: s — north (each step increases $y$ by $1$), j — south ($y$ decreases by $1$), q — east ($x$ increases by $1$), g — west ($x$ decreases by $1$). Find the coordinates of the point where the robot stops.

The robot moving across the plane in the given direction

Input

One line with four items: integers $x$ and $y$, a direction letter $c$ (s, j, q or g) and an integer $n$.

Output

One line with two integers: the $x$ and $y$ coordinates of the point where the robot stops.

Note

$-1000 \le x, y \le 1000$
$0 \le n \le 1000$

Examples

Input #1
2 1 s 3
Output #1
2 4
Input #2
0 0 g 5
Output #2
-5 0

Sign in to submit a solution

Signing up is free and takes a minute.