#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
long long Sx, Sy;
cin >> N >> M >> Sx >> Sy;
map<long long, set<long long>> row_houses, col_houses;
for (int i = 0; i < N; i++) {
long long x, y;
cin >> x >> y;
row_houses[y].insert(x);
col_houses[x].insert(y);
}
vector<pair<char, long long>> moves(M);
for (int i = 0; i < M; i++) {
cin >> moves[i].first >> moves[i].second;
}
set<pair<long long, long long>> visitedHouses;
long long x = Sx, y = Sy;
for (auto move : moves) {
char dir = move.first;
long long dist = move.second;
if (dir == 'U') {
auto it = col_houses[x].upper_bound(y);
while (it != col_houses[x].end() && *it <= y + dist) {
visitedHouses.insert({x, *it});
it++;
}
y += dist;
} else if (dir == 'D') {
auto it = col_houses[x].lower_bound(y);
while (it != col_houses[x].begin() && *prev(it) >= y - dist) {
--it;
visitedHouses.insert({x, *it});
}
y -= dist;
} else if (dir == 'L') {
auto it = row_houses[y].lower_bound(x);
while (it != row_houses[y].begin() && *prev(it) >= x - dist) {
it--;
visitedHouses.insert({*it, y});
}
x -= dist;
} else if (dir == 'R') {
auto it = row_houses[y].upper_bound(x);
while (it != row_houses[y].end() && *it <= x + dist) {
visitedHouses.insert({*it, y});
it++;
}
x += dist;
}
}
cout << x << " " << y << " " << visitedHouses.size() << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIGludCBOLCBNOwogICAgbG9uZyBsb25nIFN4LCBTeTsKICAgIGNpbiA+PiBOID4+IE0gPj4gU3ggPj4gU3k7CgogICAgbWFwPGxvbmcgbG9uZywgc2V0PGxvbmcgbG9uZz4+IHJvd19ob3VzZXMsIGNvbF9ob3VzZXM7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOOyBpKyspIHsKICAgICAgICBsb25nIGxvbmcgeCwgeTsKICAgICAgICBjaW4gPj4geCA+PiB5OwogICAgICAgIHJvd19ob3VzZXNbeV0uaW5zZXJ0KHgpOwogICAgICAgIGNvbF9ob3VzZXNbeF0uaW5zZXJ0KHkpOwogICAgfQoKICAgIHZlY3RvcjxwYWlyPGNoYXIsIGxvbmcgbG9uZz4+IG1vdmVzKE0pOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBNOyBpKyspIHsKICAgICAgICBjaW4gPj4gbW92ZXNbaV0uZmlyc3QgPj4gbW92ZXNbaV0uc2Vjb25kOwogICAgfQoKICAgIHNldDxwYWlyPGxvbmcgbG9uZywgbG9uZyBsb25nPj4gdmlzaXRlZEhvdXNlczsKCiAgICBsb25nIGxvbmcgeCA9IFN4LCB5ID0gU3k7CgogICAgZm9yIChhdXRvIG1vdmUgOiBtb3ZlcykgewogICAgICAgIGNoYXIgZGlyID0gbW92ZS5maXJzdDsKICAgICAgICBsb25nIGxvbmcgZGlzdCA9IG1vdmUuc2Vjb25kOwoKICAgICAgICBpZiAoZGlyID09ICdVJykgewogICAgICAgICAgICBhdXRvIGl0ID0gY29sX2hvdXNlc1t4XS51cHBlcl9ib3VuZCh5KTsgCiAgICAgICAgICAgIHdoaWxlIChpdCAhPSBjb2xfaG91c2VzW3hdLmVuZCgpICYmICppdCA8PSB5ICsgZGlzdCkgewogICAgICAgICAgICAgICAgdmlzaXRlZEhvdXNlcy5pbnNlcnQoe3gsICppdH0pOwogICAgICAgICAgICAgICAgaXQrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICB5ICs9IGRpc3Q7IAogICAgICAgIH0gZWxzZSBpZiAoZGlyID09ICdEJykgewogICAgICAgICAgICBhdXRvIGl0ID0gY29sX2hvdXNlc1t4XS5sb3dlcl9ib3VuZCh5KTsgCiAgICAgICAgICAgIHdoaWxlIChpdCAhPSBjb2xfaG91c2VzW3hdLmJlZ2luKCkgJiYgKnByZXYoaXQpID49IHkgLSBkaXN0KSB7CiAgICAgICAgICAgICAgICAtLWl0OwogICAgICAgICAgICAgICAgdmlzaXRlZEhvdXNlcy5pbnNlcnQoe3gsICppdH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHkgLT0gZGlzdDsgCiAgICAgICAgfSBlbHNlIGlmIChkaXIgPT0gJ0wnKSB7CiAgICAgICAgICAgIGF1dG8gaXQgPSByb3dfaG91c2VzW3ldLmxvd2VyX2JvdW5kKHgpOyAKICAgICAgICAgICAgd2hpbGUgKGl0ICE9IHJvd19ob3VzZXNbeV0uYmVnaW4oKSAmJiAqcHJldihpdCkgPj0geCAtIGRpc3QpIHsKICAgICAgICAgICAgICAgIGl0LS07CiAgICAgICAgICAgICAgICB2aXNpdGVkSG91c2VzLmluc2VydCh7Kml0LCB5fSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCAtPSBkaXN0OyAKICAgICAgICB9IGVsc2UgaWYgKGRpciA9PSAnUicpIHsKICAgICAgICAgICAgYXV0byBpdCA9IHJvd19ob3VzZXNbeV0udXBwZXJfYm91bmQoeCk7IAogICAgICAgICAgICB3aGlsZSAoaXQgIT0gcm93X2hvdXNlc1t5XS5lbmQoKSAmJiAqaXQgPD0geCArIGRpc3QpIHsKICAgICAgICAgICAgICAgIHZpc2l0ZWRIb3VzZXMuaW5zZXJ0KHsqaXQsIHl9KTsKICAgICAgICAgICAgICAgIGl0Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCArPSBkaXN0OyAKICAgICAgICB9CiAgICB9CgogICAgY291dCA8PCB4IDw8ICIgIiA8PCB5IDw8ICIgIiA8PCB2aXNpdGVkSG91c2VzLnNpemUoKSA8PCBlbmRsOwogICAgcmV0dXJuIDA7Cn0K