#906
Gold III
PRINCEZA
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Luka parked his truck near the lake. The lake is inhabited by the frog Barica, who jumps across N 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 (x, y) Barica can jump:

  • To plant (x+P, y+P), for any positive integer P. Call this direction A.

  • To plant (x+P, y−P), for any positive integer P. Call this direction B.

  • To plant (x−P, y+P), for any positive integer P. Call this direction C.

  • To plant (x−P, y−P), for any positive integer P. 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.

입력

The first line contains two integers N and K (1 ≤ N, K ≤ 100 000), the number of plants and the number of attempted jump. The second line contains K 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 N lines contains two integers X and Y (0 ≤ X ≤ 1 000 000 000, 0 ≤ Y ≤ 1 000 000 000), the coordinates of one plant. Barica is initially located on the first plant.

출력

Output Barica's final coordinates.

예제 입력 1

7 5
ACDBB
5 6
8 9
4 13
1 10
7 4
10 9
3 7

예제 출력 1

7 4

예제 입력 2

6 12
AAAAAABCCCDD
1 1
2 2
3 3
4 4
5 3
6 2

예제 출력 2

5 3
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Gold III1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.