#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
long long Sx, Sy;
cin >> N >> M >> Sx >> Sy;
map<int, set<int>> rows, cols;
for (int i = 0; i < N; i++) {
int x, y;
cin >> x >> y;
rows[y].insert(x);
cols[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 = cols[x].upper_bound(y);
while (it != cols[x].end() && *it <= y + dist) {
visitedHouses.insert({x, *it});
it++;
}
y += dist;
} else if (dir == 'D') {
auto it = cols[x].lower_bound(y);
while (it != cols[x].begin() && *prev(it) >= y - dist) {
--it;
visitedHouses.insert({x, *it});
}
y -= dist;
} else if (dir == 'L') {
auto it = rows[y].lower_bound(x);
while (it != rows[y].begin() && *prev(it) >= x - dist) {
--it;
visitedHouses.insert({*it, y});
}
x -= dist;
} else if (dir == 'R') {
auto it = rows[y].upper_bound(x);
while (it != rows[y].end() && *it <= x + dist) {
visitedHouses.insert({*it, y});
it++;
}
x += dist;
}
}
cout << x << " " << y << " " << visitedHouses.size() << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIGludCBOLCBNOwogICAgbG9uZyBsb25nIFN4LCBTeTsgCiAgICBjaW4gPj4gTiA+PiBNID4+IFN4ID4+IFN5OwoKICAgIG1hcDxpbnQsIHNldDxpbnQ+PiByb3dzLCBjb2xzOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOOyBpKyspIHsKICAgICAgICBpbnQgeCwgeTsKICAgICAgICBjaW4gPj4geCA+PiB5OwogICAgICAgIHJvd3NbeV0uaW5zZXJ0KHgpOyAKICAgICAgICBjb2xzW3hdLmluc2VydCh5KTsgCiAgICB9CgogICAgdmVjdG9yPHBhaXI8Y2hhciwgbG9uZyBsb25nPj4gbW92ZXMoTSk7IAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBNOyBpKyspIHsKICAgICAgICBjaW4gPj4gbW92ZXNbaV0uZmlyc3QgPj4gbW92ZXNbaV0uc2Vjb25kOwogICAgfQoKICAgIHNldDxwYWlyPGxvbmcgbG9uZywgbG9uZyBsb25nPj4gdmlzaXRlZEhvdXNlczsKICAgIGxvbmcgbG9uZyB4ID0gU3gsIHkgPSBTeTsKCiAgICBmb3IgKGF1dG8gbW92ZSA6IG1vdmVzKSB7CiAgICAgICAgY2hhciBkaXIgPSBtb3ZlLmZpcnN0OwogICAgICAgIGxvbmcgbG9uZyBkaXN0ID0gbW92ZS5zZWNvbmQ7CgogICAgICAgIGlmIChkaXIgPT0gJ1UnKSB7CiAgICAgICAgICAgIGF1dG8gaXQgPSBjb2xzW3hdLnVwcGVyX2JvdW5kKHkpOwogICAgICAgICAgICB3aGlsZSAoaXQgIT0gY29sc1t4XS5lbmQoKSAmJiAqaXQgPD0geSArIGRpc3QpIHsKICAgICAgICAgICAgICAgIHZpc2l0ZWRIb3VzZXMuaW5zZXJ0KHt4LCAqaXR9KTsKICAgICAgICAgICAgICAgIGl0Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeSArPSBkaXN0OwogICAgICAgIH0gZWxzZSBpZiAoZGlyID09ICdEJykgewogICAgICAgICAgICBhdXRvIGl0ID0gY29sc1t4XS5sb3dlcl9ib3VuZCh5KTsKICAgICAgICAgICAgd2hpbGUgKGl0ICE9IGNvbHNbeF0uYmVnaW4oKSAmJiAqcHJldihpdCkgPj0geSAtIGRpc3QpIHsKICAgICAgICAgICAgICAgIC0taXQ7CiAgICAgICAgICAgICAgICB2aXNpdGVkSG91c2VzLmluc2VydCh7eCwgKml0fSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeSAtPSBkaXN0OwogICAgICAgIH0gZWxzZSBpZiAoZGlyID09ICdMJykgewogICAgICAgICAgICBhdXRvIGl0ID0gcm93c1t5XS5sb3dlcl9ib3VuZCh4KTsKICAgICAgICAgICAgd2hpbGUgKGl0ICE9IHJvd3NbeV0uYmVnaW4oKSAmJiAqcHJldihpdCkgPj0geCAtIGRpc3QpIHsKICAgICAgICAgICAgICAgIC0taXQ7CiAgICAgICAgICAgICAgICB2aXNpdGVkSG91c2VzLmluc2VydCh7Kml0LCB5fSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCAtPSBkaXN0OwogICAgICAgIH0gZWxzZSBpZiAoZGlyID09ICdSJykgewogICAgICAgICAgICBhdXRvIGl0ID0gcm93c1t5XS51cHBlcl9ib3VuZCh4KTsKICAgICAgICAgICAgd2hpbGUgKGl0ICE9IHJvd3NbeV0uZW5kKCkgJiYgKml0IDw9IHggKyBkaXN0KSB7CiAgICAgICAgICAgICAgICB2aXNpdGVkSG91c2VzLmluc2VydCh7Kml0LCB5fSk7CiAgICAgICAgICAgICAgICBpdCsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHggKz0gZGlzdDsKICAgICAgICB9CiAgICB9CgogICAgY291dCA8PCB4IDw8ICIgIiA8PCB5IDw8ICIgIiA8PCB2aXNpdGVkSG91c2VzLnNpemUoKSA8PCBlbmRsOwoKICAgIHJldHVybiAwOwp9Cg==