407918: GYM102942 A Directional Move

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Directional Movetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

There is a binary string consisting of characters '0' and '1'. Initially, Bob is facing East when he starts reading the binary string. When he sees a '0', he turns $$$90^\circ$$$ to his right. When he sees a '1', he turns $$$90^\circ$$$ to his left.

The four directions are as follows: East is denoted by 'E', West by 'W', North by 'N', and South by 'S'.

After reading the entire string, which direction will Bob face?

Input

The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^{2})$$$ $$$-$$$ the number of test cases in the input.

Then $$$t$$$ test cases follow.

The first line of the test case contains one integer $$$n$$$ $$$( 1 \leq n \leq 10^{5} )$$$.

The second line of the test case contains a string $$$s$$$ of $$$n$$$ characters, consisting only '0' and '1'.

It is guaranteed that the sum of the values of $$$n$$$ for all test cases in the input does not exceed $$$2\cdot10^{5}$$$.

Output

For each test case, Print a single character — the direction Bob is facing after reading the string.

ExampleInput
3
4
1010
5
00000
3
111
Output
E
S
S
Note

In the first test, for the first two moves, Bob turns $$$90^{\circ}$$$ left and then turns $$$90^{\circ}$$$ right. So, he is back to his initial orientation. Again he repeats the same for the other two moves. So his final direction is East.

In the second test, After $$$4$$$ moves Bob is back to his initial orientation, and after the next $$$90^{\circ}$$$ right move, he will be facing South.

加入题单

算法标签: