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 = "#Program question at: http://www.codechef.com/COZL2012/problems/RBX12R01\nimport math,sys\ndir_ = 'UDLR'\nleft = 'LRDU'\nright = 'RLUD'\n\nt = int(input())\nwhile t>0:\n t -= 1\n x=0; y=0;\n dr = ''; cur='U';\n s = input().split()\n l = len(s)\n for i in range(l):\n  if i % 2 == 1:\n   dr = s[i]\n   if dr == 'L': cur = left[dir_.find(cur)]\n   else: cur = right[dir_.find(cur)]\n  else:\n   steps = int(s[i])\n   if cur == 'U': y += steps\n   elif cur == 'D': y -= steps\n   elif cur == 'L': x -= steps\n   elif cur == 'R': x += steps\n\n dist = str(math.sqrt(x*x + y*y))\n i = dist.find('.')\n sys.stdout.write(dist[0:i+2])\n if x==0:\n  sys.stdout.write( ('N' if y>0 else 'S') + '\\n')\n elif y==0:\n  sys.stdout.write( ('E' if x>0 else 'W') + '\\n')\n elif x>0:\n  sys.stdout.write( ('NE' if y>0 else 'SE') + '\\n')\n elif x<0:\n   sys.stdout.write( ('NW' if y>0 else 'SW') + '\\n')\n\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13781