#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<iterator>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<string>
#include<map>
#include<functional>
#include<utility>
#include<vector>
#include<deque>
#include<iomanip>
typedef long long LL;
typedef unsigned long UL;
using namespace std;
int main()
{
string str;
int map=1;
while(true)
{
cin>>str;
if(str=="END")
break;
float x=10e-6,y=10e-6;
int len=str.length();
for(int i=0;i<len-1;)
{
string s,st;
while(isdigit(str[i]))
{
s+=str[i];
i++;
}
st+=str[i];
i++;
if(str[i]!=','&& str[i]!='.')
st+=str[i];
i++;
// cout<<s<<" "<<st<<endl;
int l=s.length();
double temp=0;
int mult=1;
for(int i=l-1;i>=0;i--)
{temp+=(s[i]-'0')*mult;mult*=10;}
//cout<<temp<<endl;
if(st=="N")
{ y+=temp;}
else if(st=="S")
y-=temp;
else if(st=="E")
x+=temp;
else if(st=="W")
x-=temp;
else if(st=="SW")
{
x-=temp*sin(2*acos(0)/4);y-=temp*sin(2*acos(0)/4);
}
else if(st=="NW")
{x-=temp*sin(2*acos(0)/4);y+=temp*sin(2*acos(0)/4);}
else if(st=="NE")
{x+=temp*sin(2*acos(0)/4);y+=temp*sin(2*acos(0)/4);}
else if(st=="SE")
{x+=temp*sin(2*acos(0)/4);y-=temp*sin(2*acos(0)/4);}
//cout<<x<<" "<<y<<endl;
//cout<<x<<" "<<y<<endl;
}
cout<<"Map #"<<map<<"\n";
map++;
printf("The treasure is located at (%.3f,%.3f).\n",x,y);
printf("The distance to the treasure is %.3lf.\n\n", sqrt(x*x+y*y));
}
// system("pause");
}
