Find Your Gift
All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/COOK116/mandarin/GIFTSRC.pdf),[Vietnamese](http://www.codechef.com/download/translated/COOK116/vietnamese/GIFTSRC.pdf), and [Bengali](http://www.codechef.com/download/translated/COOK116/bengali/GIFTSRC.pdf) 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 \le T \le 100$ - $1 \le N \le 1,000$ - $S$ contains only characters 'L', 'R', 'U' and 'D' ### Example Input ``` 3 5 LLLUR 7 LLLRUUD 8 LRULLUDU ``` ### Example Output ``` 0 1 -1 1 -2 2 ``` ### Explanation **Example case 1:** Chef's path is $(0,0) \rightarrow (-1,0) \rightarrow (-1,0) \rightarrow (-1,0) \rightarrow (-1,1) \rightarrow (0,1)$.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, CPP17, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.