#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int inf = 1e9;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
char dc[5] = "NESW";

struct state{
	int x,y,d;
	state(int x, int y, int d):x(x),y(y),d(d){}
	state(){}
	bool operator<(const state &a) const{
		return x!=a.x? x<a.x: y!=a.y? y<a.y: d<a.d;
	}
};

int main(){
	int n,sx,sy,t;
	cin >> n >> sx >> sy >> t;
	
	bool adj[51][51][4];
	memset(adj, 0, sizeof(adj));
	for(int i=0; i<n; i++){
		int xs,ys,xe,ye;
		cin >> xs >> ys >> xe >> ye;
		if(xs == xe){
			if(ys > ye) swap(ys, ye);
			for(int y=ys; y<ye; y++){
				adj[xs][y][0] = true;
				adj[xs][y+1][2] = true;
			}
		}else{
			if(xs > xe) swap(xs, xe);
			for(int x=xs; x<xe; x++){
				adj[x][ys][1] = true;
				adj[x+1][ys][3] = true;
			}
		}
	}
	
	set<state> curr;
	for(int i=0; i<4; i++){
		if(adj[sx][sy][i]){
			curr.insert(state(sx, sy, i));
		}
	}
	for(int i=0; i<t; i++){
		int d;
		char last;
		cin >> d >> last;
		int ld;
		for(int i=0; i<4; i++){
			if(dc[i] == last) ld = i;
		}
		for(int j=0; j<d; j++){
			set<state> next;
			for(state e: curr){
				int nx = e.x +dx[e.d];
				int ny = e.y +dy[e.d];
				for(int dir=0; dir<4; dir++){
					if((dir+2)%4 == e.d) continue;
					if(!adj[nx][ny][dir]) continue;
					if(j==d-1 && dir!=ld && e.d!=ld) continue;
					next.insert(state(nx, ny, dir));
				}
			}
			curr = next;
		}
	}
	
	set<state> unique;
	for(state e: curr){
		unique.insert(state(e.x, e.y, 0));
	}
	for(state e: unique){
		cout << e.x << " " << e.y << endl;
	}
	return 0;
}
