#include <bits/stdc++.h>
using namespace std;
int n, m, dx, dy;
int posx[2000002];
int posy[2000002];
int indx[2000002];
int indy[2000002];
int d[2000002];
int main() {
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  for (int i = 0, curx = 0, cury = 0; i < n;
       ++i, curx = (curx + dx) % n, cury = (cury + dy) % n) {
    posx[i] = curx;
    posy[i] = cury;
    indx[curx] = i;
    indy[cury] = i;
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    int k = indy[y];
    int ind = (indx[x] - k + n) % n;
    ++d[posx[ind]];
  }
  int best = 0;
  for (int i = 0; i < n; ++i)
    if (d[i] > d[best]) best = i;
  printf("%d %d\n", best, 0);
  return 0;
}
