#55601: python求解,我一直OLE


raymond08200305@gmail.com (嗨起來)


import math
s=1
while True:
    n=input();x=0;y=0;
    if n=="END": break
    n1=n[:-1].split(",")
    for i in n1:
        a,b="",""
        for j in i:
            if j.isdigit(): a+=j
            else: b+=j
        if b=="N": y+=int(a)
        elif b=="S": y-=int(a)
        elif b=="W": x-=int(a) 
        elif b=="E": x+=int(a)
        elif b=="NW": 
            x-=int(a)*math.sqrt(2)/2
            y+=int(a)*math.sqrt(2)/2
        elif b=="NE": 
            x+=int(a)*math.sqrt(2)/2
            y+=int(a)*math.sqrt(2)/2
        elif b=="SW": 
            x-=int(a)*math.sqrt(2)/2
            y-=int(a)*math.sqrt(2)/2
        elif b=="SE": 
            x+=int(a)*math.sqrt(2)/2
            y-=int(a)*math.sqrt(2)/2
    t=math.sqrt(x**2+y**2)

    print(f"Map #{s}");s+=1
    print(f"The treasure is located at ({x:.03f},{y:.03f}).")
    print(f"The distance to the treasure is {t:.03f}.")
    print()