#K41107. Spaceship Final Coordinates

    ID: 26792 Type: Default 1000ms 256MiB

Spaceship Final Coordinates

Spaceship Final Coordinates

A spaceship is navigating through space following a series of commands. For each command sequence, you are given the number of commands and the commands themselves. The commands instruct the spaceship to move in one of four directions:

  • move up: decreases the y-coordinate by 1
  • move down: increases the y-coordinate by 1
  • move left: decreases the x-coordinate by 1
  • move right: increases the x-coordinate by 1

Initially, the spaceship is at the origin \((0,0)\). After executing the commands in a sequence, output the final coordinates \((x, y)\). Your program must handle multiple test sequences in one run.

inputFormat

The input is read from standard input (stdin) and has the following format:

T
N₁
command₁
command₂
…
commandₙ₁
N₂
command₁
command₂
…
commandₙ₂
…

Here, T is the number of command sequences. For each sequence, the first line is an integer N that indicates the number of commands, followed by N lines, each containing one command.

outputFormat

For each command sequence, output a line with two integers separated by a space representing the final coordinates (x, y) of the spaceship after executing the commands.

## sample
1
3
move up
move up
move left
-1 -2

</p>