P17485 [CodeChef] GIFTSRC
普及-
题目描述

Read problems statements in [Mandarin Chinese],[Vietnamese], and [Bengali] as well.

Today is Chef's birthday and he is looking forward to his gift. As usual, the gift is hidden and Chef has to follow a sequence of $N$ instructions to reach it.

Initially, Chef is standing in the cell $(0, 0)$ of a two-dimensional grid. The sequence of instructions is given as a string $S$. If we denote Chef's current cell by $(x, y)$, each character of $S$ corresponds to an instruction as follows:
'L' means to go left, i.e. to the cell $(x-1, y)$
'R' means to go right, i.e. to the cell $(x+1, y)$
'U' means to go up, i.e. to the cell $(x, y+1)$
'D' means to go down, i.e. to the cell $(x, y-1)$

In addition, Chef should never perform multiple consecutive moves along the same axis of the grid. If there are multiple consecutive instructions to move along the same axis (left/right or up/down), he should perform only the first of these moves.

Find the cell $(x_{g}, y_{g})$ which contains the hidden gift.

------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains a single string $S$ with length $N$.

------ Output ------
For each test case, print a single line containing two space-separated integers $x_{g}$ and $y_{g}$.

------ Constraints ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 1,000$
$S$ contains only characters 'L', 'R', 'U' and 'D'

----- Sample Input 1 ------
3

5

LLLUR

7

LLLRUUD

8

LRULLUDU
----- Sample Output 1 ------
0 1

-1 1

-2 2
----- explanation 1 ------
Example case 1: Chef's path is $(0,0) \rightarrow (-1,0) \rightarrow (-1,0) \rightarrow (-1,0) \rightarrow (-1,1) \rightarrow (0,1)$.

输入格式

见题面

输出格式

见题面

样例输入
3 5 LLLUR 7 LLLRUUD 8 LRULLUDU
样例输出
0 1 -1 1 -2 2