import java.io.*;
import java.util.*;
import java.math.*;

public class game_nn implements Runnable {

	void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int r = sc.nextInt();
		int max = r;
		int min = r;
		int ans1 = -1;
		int ans2 = -1;
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			int a = sc.nextInt();			
			if (a == 1 && b == 1) {
				max += k;
				min -= k;
			} else if (a == 1) {
				max++;
				min++;
			} else if (b == 1) {
				max--;
				min--;
			}
			if (ans1 == -1 && max > m) {
				ans1 = i + 1;
			}
			if (ans2 == -1 && min < -m) {
				ans2 = i + 1;
			}
		}
		out.println(ans1 + " " + ans2);
	}

	FastScanner sc;
	PrintWriter out;

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner("game.in");
			out = new PrintWriter("game.out");
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	class FastScanner extends BufferedReader {
		StringTokenizer st;
		boolean eof;
		String buf;
		String curLine;
		boolean createST;

		public FastScanner(String fileName) throws FileNotFoundException {
			this(fileName, true);
		}

		public FastScanner(String fileName, boolean createST)
				throws FileNotFoundException {
			super(new FileReader(fileName));
			this.createST = createST;
			nextToken();
		}

		public FastScanner(InputStream stream) {
			this(stream, true);
		}

		public FastScanner(InputStream stream, boolean createST) {
			super(new InputStreamReader(stream));
			this.createST = createST;
			nextToken();
		}

		String nextLine() {
			String ret = curLine;
			if (createST) {
				st = null;
			}
			nextToken();
			return ret;
		}

		String nextToken() {
			if (!createST) {
				try {
					curLine = readLine();
				} catch (Exception e) {
					eof = true;
				}
				return null;
			}
			while (st == null || !st.hasMoreTokens()) {
				try {
					curLine = readLine();
					st = new StringTokenizer(curLine);
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		BigInteger nextBigInteger() {
			return new BigInteger(nextToken());
		}

		public void close() {
			try {
				buf = null;
				st = null;
				curLine = null;
				super.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	public static void main(String[] args) {
		new game_nn().run();
	}
}
