Luka parked his truck near the lake. The lake is inhabited by the frog Barica, who jumps across plants floating on the lake's surface. Knowing a fair number of folk tales, Luka knows that if he kisses Barica, she will turn into a beautiful princess. However, he needs to catch her first!
Assuming an aerial view, the position of a plant on the lake's surface can be defined with a pair of coordinates. From plant Barica can jump:
- To plant , for any positive integer . Call this direction
A
. - To plant , for any positive integer . Call this direction
B
. - To plant , for any positive integer . Call this direction
C
. - To plant , for any positive integer . Call this direction
D
.
Barica selects one of the four directions and jumps onto the first plant in the chosen direction. If there is no plant in the selected direction, Barica stays where she is. After Barica jumps, the plant she jumped from sinks and disappears.
Knowing the locations of the plants and the sequence of directions Barica chooses, Luka wants to determine coordinates of the plant Barica will end up on. Luka will wait for her at that plant, ambush her and kiss her.
Write a program that solves Luka's problem and helps him turn Barica into a beautiful princess.
Input Specification
The first line contains two integers and , the number of plants and the number of attempted jumps.
The second line contains letters each of which is A
, B
, C
or D
. These letters represent in order
the directions in which Barica attempts to jump.
Each of the following lines contains two integers and , the coordinates of one plant. Barica is initially located on the first plant.
Output Specification
Output Barica's final coordinates.
Sample Input 1
7 5
ACDBB
5 6
8 9
4 13
1 10
7 4
10 9
3 7
Sample Output 1
7 4
Sample Input 2
6 12
AAAAAABCCCDD
1 1
2 2
3 3
4 4
5 3
6 2
Sample Output 2
5 3
Comments