#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

struct edge {
	int to, dir;
};

vector<edge> G[3600];
bool used[3600][4];

int trans(char t) {
	if (t == 'N')return 0;
	else if (t == 'E')return 1;
	else if (t == 'S')return 2;
	else return 3;
}

void solve() {
	int n, sx, sy, t;
	cin >> n >> sy >> sx >> t;
	int s = sx * 60 + sy;
	rep(i, n) {
		int x[2], y[2];
		cin >> y[0] >> x[0] >> y[1] >> x[1];
		if (x[0] == x[1]) {
			if (y[0] > y[1])swap(y[0], y[1]);
			for (int j = y[0]; j < y[1]; j++) {
				int le = x[0] * 60 + j;
				int ri = x[0] * 60 + j + 1;
				G[le].push_back({ ri,1 });
				G[ri].push_back({ le,3 });
			}
		}
		else {
			if (x[0] > x[1])swap(x[0], x[1]);
			for (int j = x[0]; j < x[1]; j++) {
				int le = j * 60 + y[0];
				int ri = (j + 1) * 60 + y[0];
				G[le].push_back({ ri,0 });
				G[ri].push_back({ le,2 });
			}
		}
	}
	queue<P> q,nex,cop;
	rep(i, 4) {
		q.push({ s,i });
	}
	rep(aa, t) {
		int x; char z; cin >> x >> z;
		rep(bb, x) {
			//cout << bb << endl;
			rep(i, 3600)rep(j, 4)used[i][j] = false;
			while (!q.empty()) {
				P p = q.front(); q.pop();
				int id = p.first;
				int d = p.second;
				//cout << id << " " << d << endl;
				rep(j, G[id].size()) {
					int to = G[id][j].to;
					int dir = G[id][j].dir;
					if (dir == (d ^ 2))continue;
					if (used[to][dir])continue;
					used[to][dir] = true;
					nex.push({ to,dir });
				}
			}
			while (!nex.empty())q.push(nex.front()), nex.pop();
		}
		int u = trans(z);
		while (!q.empty()) {
			P p = q.front(); q.pop();
			int dir = p.second;
			//cout << p.first << " " << dir << endl;
			if (dir == (u ^ 2))continue;
			if (dir == u) {
				cop.push(p);
			}
			else {
				int id = p.first;
				rep(j, G[id].size()) {
					if (G[id][j].dir == u) {
						if (aa == t - 1) {
							cop.push(p);
						}
						else {
							nex.push({ G[id][j].to,G[id][j].dir });
						}
					}
				}
			}
		}
		while (!cop.empty())q.push(cop.front()), cop.pop();
	}
	vector<P> ans;
	while (!q.empty()) {
		int id = q.front().first; q.pop();
		ans.push_back({ id % 60,id / 60 });
	}
	sort(ans.begin(), ans.end());
	ans.erase(unique(ans.begin(), ans.end()), ans.end());

	rep(i, ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 3312