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

public class game_pk implements Runnable {
	public static void main(String[] args) {
		new Thread(new game_pk()).start();
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

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

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

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

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		int r = nextInt();
		int s = -1;
		int v = -1;
		int min = r;
		int max = r;
		for (int i = 0; i < n; i++) {
			boolean a = (nextInt() == 1);
			boolean b = (nextInt() == 1);
			if ((a) && (!b)) {
				min--;
				max--;
			}
			if ((!a) && (b)) {
				min++;
				max++;
			}
			if ((a) && (b)) {
				min -= k;
				max += k;
			}
			if ((min < -m) && (v == -1)) 
				v = i + 1;
			if ((max > m) && (s == -1)) 
				s = i + 1;
			
				
		}
		out.print(s);
		out.print(' ');
		out.println(v);
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader("game.in"));
			out = new PrintWriter("game.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}