MREŽA
문제
Two whole numbers A and B and a coordinate system in a plane are given. The origin (0,0) is labeled “start” and a point with coordinates (A,B) is labeled “end”. A figure is placed at the origin. A sequence of steps the figure has to perform is also given. Each step consists of a move from a current point to any of the four closest points with integer coordinates lying up, down, left and right. For example, moving one step up means going from (x,y) to (x,y+1); moving one step left means going from (x,y) to (x-1,y). If the figure is located at the point (x,y) then we calculate its distance from the end point by the formula
d((x,y),(A,B)) = abs(x-A) + abs(y-B).
Your task is to write a program that will find and remove a consecutive subsequence out of the given sequence of steps under the following two conditions:
- The distance between the end point and the last position of the figure is minimal possible.
- The figure never leaves the rectangle whose diagonal points are the origin and the end point and whose sides are parallel with the coordinate axes.
입력
The first line of input file contains two whole numbers A and B, the coordinates of end point separated by a space character, 1 ≤ A, B ≤ 4000.
The second line contains a whole number N, the number of steps, 1 ≤ N ≤ 8000.
The third line contains a sequence of length N of characters. Each character of a sequence can be any of characters 'R' - right , 'U' - up, 'L' - left, 'D' – down. The sequence defines the sequence of steps the figure has to perform.
Note: Each set of input data will require removal of at least one step.
출력
The first and only line of output file should contain two whole numbers K and L separated by one space character, 1 ≤ K ≤ L ≤ N, meaning that all steps beginning with Kth and ending with Lth should be removed from the sequence of steps given in the input file.
예제
예제 1
2 3 5 RURRR
3 4
예제 2
2 2 5 RDLUR
2 3
예제 3
3 3 11 UUUURRRRDDL
4 5