Mirko created a new robot and decided to test it on a giant test track. We can imagine the test track as
2D coordinate system. The robot starts at a point
More precisely, if a robot is located in S
(north) means it should move to J
(south)
means it should move to I
(east) means it should move to Z
(west) means it
should move to
While robot is receiving instructions and moves through the test track, Mirko is verifying its position in
the following manner. Test track contains
Assuming that robot moves by the instructions without error, calculate the sum of distances to all control points after each instruction.
Remark: Manhattan-distance of the points
Input Specification
First line of input contains positive integers
Each of the following
The following line contains a string of
Output Specification
Output
Sample Input 1
1 3
0 -10
ISI
Sample Output 1
11
12
13
Sample Input 2
3 5
0 0
1 1
1 -1
SIJJZ
Sample Output 2
5
4
3
4
5
Comments