TRATINČICE | 프로그래밍의 벗 PivotOJ
PivotOJ

TRATINČICE

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2012 Junior Croatian Olympiad in Informatics - Exam #2BOJ 3089
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

As Mirko was carelessly picking clovers, he was possesed by aliens and he was now under their control. The field is a Cartesian coordinate system containing N points representing clovers. 

His parents found out he was possesed and they managed to get info on how aliens control him. The aliens first place him at point (0, 0), and then perform M steps where in each step they pick a direction (up, down, left or right) and send him from his current location to the next clover in that direction. 

[이미지 1]

For given field of clovers and descriptions of M steps, help Mirko's parents determine where will he end up after the aliens finish their control. 

입력

First line contains two integers N and M (3 ≤ N ≤ 100 000, 1 ≤ M ≤ 100 000), the number of clovers and the number of steps. 

Each of the following N lines contains two integers Xi and Yi (-100 000 < Xi, Yi < 100 000), coordinates of the i-th clover. These points will be mutually distinct. 

Last line contains a sequence of M charactes, where the i-th character represents the direction in the i-th step. L stands for left, R for right, U for up and D for down. Steps are carried out as from left to right and there will always be a clover in a given direction. 

출력

In one and only line output the coordinates (x, y) which represent Mirko's location after those M steps. 

예제

예제 1

입력
4 4
1 1
1 0
0 1
0 0
RULD
출력
0 0

예제 2

입력
7 5
0 0
0 1
0 -1
1 0
1 -1
3 0
3 -1
DRRUD
출력
3 -1

예제 3

입력
10 6
0 0
1 1
2 1
0 2
-1 2
-1 3
2 3
2 4
4 3
2 -1
ULURDL
출력
1 1
코드를 제출하려면 로그인하세요.