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 = "\ndef my_sqrt(v):\n v*=100\n lo=0\n hi=v\n while lo+1<hi:\n  mi = (lo + hi) >> 1\n  if mi*mi<=v:\n   lo=mi\n  else:\n   hi=mi\n return lo\n\ndef solve():\n dir=0\n dx=[0,-1,0,1]\n dy=[1,0,-1,0]\n x,y=0,0\n line=input()\n ss=line.split()\n n=len(ss)\n i=0\n while(i<n):\n  if(ss[i]=='L'):\n   dir=(dir+1)%4\n  elif ss[i]=='R':\n   dir=(dir+3)%4\n  else:\n   x+=dx[dir]*int(ss[i])\n   y+=dy[dir]*int(ss[i])\n  i=i+1\n if x==0 and y==0:\n  print('0.0')\n  return\n v = my_sqrt(x*x+y*y)\n ds=''\n if(y>0):\n  ds+='N'\n elif y<0:\n  ds+='S'\n if(x>0):\n  ds+='E'\n elif x<0:\n  ds+='W'\n print('%d.%d%s' % (v/10, v%10,ds))\n\nT=int(input())\nwhile(T>0):\n T=T-1\n solve()"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13119