#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 114514;
int n, q, cnt;
ll x, y;
map <ll, set <ll>> heng, zong;
int main() {
scanf("%d%d%lld%lld", &n, &q, &x, &y);
for (int i = 1; i <= n; i++) {
int a, b;
scanf("%d%d", &a, &b);
if (a == x && b == y) {
++cnt;
continue;
}
heng[a].insert(b);
zong[b].insert(a);
}
while (q--) {
char op;
int c;
cin >> op >> c;
if (op == 'L') {
ll sx = x - c;
auto it1 = zong[y].lower_bound(sx);
auto it2 = zong[y].lower_bound(x);
for (auto it = it1; it != it2; ) {
++cnt;
heng[*it].erase(y);
it = zong[y].erase(it);
}
x = sx;
} else if (op == 'R') {
ll sx = x + c;
auto it1 = zong[y].lower_bound(x);
auto it2 = zong[y].lower_bound(sx);
for (auto it = it1; it != it2; ) {
++cnt;
heng[*it].erase(y);
it = zong[y].erase(it);
}
x = sx;
} else if (op == 'U') {
ll sy = y + c;
auto it1 = heng[x].lower_bound(y);
auto it2 = heng[x].lower_bound(sy);
for (auto it = it1; it != it2; ) {
++cnt;
zong[*it].erase(x);
it = heng[x].erase(it);
}
y = sy;
} else if (op == 'D') {
ll sy = y - c;
auto it1 = heng[x].lower_bound(sy);
auto it2 = heng[x].lower_bound(y);
for (auto it = it1; it != it2; ) {
++cnt;
zong[*it].erase(x);
it = heng[x].erase(it);
}
y = sy;
}
}
printf("%lld %lld %d\n", x, y, cnt);
return 0;
}
又搞 set + map 大型 stl 题。。