{
  CTU Open Contest 2002
  =====================
  Sample solution for the problem: route

  Martin Kacer, Oct 2002
}

Program Treasure;

Const MAXLINE = 256;

Var Row: String (MAXLINE);
	X, Y: Real;


{read the path description from the string stored in 'Row'}
Procedure ReadMap;
Var I: Integer;
	S, DX, DY: Integer;
	SR: Real;
Begin
	X := 0; Y := 0;
	I := 0;
	Repeat
		Inc (I);
		S := 0;
		While (Row[I] >= '0') and (Row[I] <= '9') do
		Begin
			S := S * 10 + Ord (Row[I]) - Ord ('0');
			Inc (I);
		End;
		DX := 0; DY := 0;
		While (Row[I] <> ',') and (Row[I] <> '.') do
		Begin
			Case Row[I] of
				'N': DY := 1;
				'S': DY := -1;
				'W': DX := -1;
				'E': DX := 1;
			End; { case }
			Inc (I);
		End;
		If (DX = 0) or (DY = 0) then
			SR := S
		else
			SR := S / Sqrt(2);
		X := X + SR * DX;
		Y := Y + SR * DY;
		until Row[I] = '.';
End;


Begin
	Repeat
		ReadLn (Row);
		If (Row[1] <> 'E') then
		Begin
			ReadMap;
			WriteLn ('You can go to (', X:1:3, ',', Y:1:3, '), the distance is ', Sqrt (X*X + Y*Y):1:3, ' steps.');
		End;
	until (Row[1] = 'E');
End.

