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 = "#!/usr/bin/env python\n\nfrom math import sqrt\n\ndef process(S):\n P = [0,0,'S']\n for i in S:\n  if i == 'L':\n   if P[-1] == 'N': P[-1] = 'W'\n   elif P[-1] == 'S': P[-1] = 'E'\n   elif P[-1] == 'E': P[-1] = 'N'\n   elif P[-1] == 'W': P[-1] = 'S'\n  elif i == 'R':\n   if P[-1] == 'N': P[-1] = 'E'\n   elif P[-1] == 'S': P[-1] = 'W'\n   elif P[-1] == 'E': P[-1] = 'S'\n   elif P[-1] == 'W': P[-1] = 'N'\n  else:\n   i = int(i)\n   if P[-1] == 'N': P[1] -= i\n   elif P[-1] == 'S': P[1] += i\n   elif P[-1] == 'E': P[0] += i\n   elif P[-1] == 'W': P[0] -= i\n  #print i, P\n DIST = sqrt(P[0]**2+P[1]**2)\n\n if P[0] == 0 and P[1] == 0: DIR = ''\n elif P[0] == 0 and P[1] < 0: DIR = 'S'\n elif P[0] == 0 and P[1] > 0: DIR = 'N'\n elif P[0] < 0 and P[1] == 0: DIR = 'E'\n elif P[0] < 0 and P[1] < 0: DIR = 'SE'\n elif P[0] < 0 and P[1] > 0: DIR = 'NE'\n elif P[0] > 0 and P[1] == 0: DIR = 'W'\n elif P[0] > 0 and P[1] < 0: DIR = 'SW'\n elif P[0] > 0 and P[1] > 0: DIR = 'NW'\n\n DIST = int(DIST*10.)/10. # TOLD NO APPROXIMATION\n\n return '%.1f%s' % (DIST, DIR)\n\ndef main():\n T = int(input())\n for t in range(T):\n  S = input().split()\n  print(process(S))\n\nmain()\n\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13463