#include <bits/stdc++.h>
using namespace std;
int f[1000005];
int main() {
  int n, m, dx, dy, x, y;
  scanf("%d %d %d %d", &n, &m, &dx, &dy);
  dx %= n;
  dy %= n;
  x = 0, y = 0;
  if (n > 1) {
    while (x != 1) {
      x += dx;
      if (x >= n) x -= n;
      y += dy;
      if (y >= n) y -= n;
    }
  }
  dy = y;
  int maxx = 0, maxy = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    int t = ((y - 1LL * x * dy) % n + n) % n;
    if (++f[t] > maxx) {
      maxx = f[t];
      maxy = t;
    }
  }
  printf("0 %d\n", maxy);
  return 0;
}
