#include <bits/stdc++.h>
using namespace std;
int qnt[1001000];
int py[1001000];
int main() {
  int n, m, dx, dy;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    py[x] = y;
    x = (x + dx) % n;
    y = (y + dy) % n;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    int sobe = (b + n - py[a]) % n;
    qnt[sobe]++;
  }
  int best = 0;
  for (int i = 1; i < n; i++)
    if (qnt[i] > qnt[best]) best = i;
  printf("0 %d\n", best);
}
