Mr. X stays in a mansion whose door opens in the North. He travels every morning to meet his friend Ms. Y walking a predefined path.

To cut the distance short, one day he decides to construct a skywalk from his place to his friend’s place. Help him to find the shortest distance between the two residences.


-----Input-----

The first line contains a single positive integer T <= 100, the number of test cases. T test cases follow. The only line of each test case contains a string which is the path from X to Y. The integer value represents the distance. The character R or L represents a Right or a Left respectively.

-----Output-----

For each test case, output a single line containing the minimum distance and the direction(N,S,W,E,NE,NW,SE,SW) of Y’s residence with respect to X’s residence. The output distance should have only 1 decimal place with no approximation. Print “0.0” if X’s and Y’s residence coincide.

-----Example-----
Input:
1
2 L 2 R 2 L 1

Output:
5.0NW

Explanation
Mr. X travels 2units and then takes a Left, and then he travels 2units and takes a Right, then after travelling 2units he takes a Left and finally travels 1unit to reach Y’s residence.
(Unlike Input, Output does not have spaces between the distance and direction)

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '#input must be invalid because no runtime error after handling invalid input\n\ndef parse(movestr):\n moves = []\n acc = ""\n for char in movestr:\n  char = char.upper()\n  if char == "R" or char == "L":\n   if acc != "":\n    moves.append(int(acc))\n   acc = ""\n   moves.append(char)\n  elif char.isdigit():\n   acc += char\n  elif len(acc) > 0:\n   moves.append(int(acc))\n   acc = ""\n   \n if len(acc) > 0:\n  moves.append(int(acc))\n return moves\n\n\ndef make_move(x,y,direc,dist):\n if direc == 0:\n  #north\n  y += dist\n elif direc == 1:\n  #west\n  x -= dist\n elif direc == 2:\n  #south\n  y -= dist\n elif direc == 3:\n  #east\n  x += dist\n return x,y\n\n\ndef calc(moves):\n x,y = 0,0\n direc = 0\n for move in moves:\n  if move == "L":\n   direc = (direc+1)%4\n  elif move == "R":\n   direc = (direc-1)%4\n  else:\n   x,y = make_move(x,y,direc,move)\n return x,y\n\n\ndef string(dist):\n d = str(dist)\n k = d.find(".")\n return d[:k+2]\n\ncases = int(input())\nfor case in range(cases):\n movestr = input().replace(" ","")\n moves = parse(movestr)\n x,y = calc(moves)\n dist = (x**2 + y**2)**0.5\n \n if x == 0:\n  if y == 0:\n   direc = ""\n  elif y < 0:\n   direc = "S"\n  else:\n   direc = "N"\n elif x < 0:\n  if y == 0:\n   direc = "W"\n  elif y < 0:\n   direc = "SW"\n  else:\n   direc = "NW"\n else:\n  if y == 0:\n   direc = "E"\n  elif y < 0:\n   direc = "SE"\n  else:\n   direc = "NE"\n print("%s%s" %(string(dist),direc))'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13755