Arggggggh!

Follow a start point and a series of compass moves to compute the final coordinates, rounded to 8 decimals.

Easy2ImplementationMathSimulationNo attempts yetTime limit2sMemory limit512 MB

Problem

You inherited a treasure map from a long dead ancestor who was a pirate. Instead of a picture with a big X on it, the map is a list of instructions that walks you to the spot where you should start digging.

The first instruction is the starting location, given as two integers xx and yy. Every later instruction is a direction and a distance. N 7 means walk 7 feet north, and SW 6 means walk 6 feet southwest. Follow all of them in order and you end up standing over the digging spot.

Moving north increases yy and leaves xx unchanged. Moving east increases xx and leaves yy unchanged. A diagonal move of dd feet changes both coordinates by d/2d/\sqrt{2}. NE adds d/2d/\sqrt{2} to xx and to yy, SE adds it to xx and subtracts it from yy, SW subtracts it from both, and NW subtracts it from xx and adds it to yy.

Walking the whole route one instruction at a time takes a while, so compute the final location and go straight there.

One more thing: the ancestor was a Pittsburgh Pirate, and the treasure is a pile of old baseballs and a very moldy mitt.

Input

The first line contains one integer nn (1n1001 \le n \le 100), the number of instructions.

Each of the next nn lines contains one instruction. The first instruction is two integers xx and yy (0x,y1000 \le x, y \le 100), the starting point. Each remaining instruction has the form dir d, where dir is one of N, NE, E, SE, S, SW, W, NW and dd (1d1001 \le d \le 100) is the distance to walk.

Output

Print the xx and yy coordinates of the final location on one line, separated by a single space. Round both values to 8 decimal places and always print exactly 8 digits after the decimal point.

Every coordinate is either an integer or an irrational number, so it never lands exactly on a rounding boundary. When a coordinate is zero, print 0.00000000 and not -0.00000000.