#include <bits/stdc++.h>
using namespace std;
int cnt[1000100], offset[1000100];
int main() {
  int n, m, dx, dy, i, j;
  cin >> n >> m >> dx >> dy;
  int x = 0, y = 0;
  for (i = 0; i < n; i++) {
    offset[y] = x;
    x = (x + dx) % n;
    y = (y + dy) % n;
  }
  int bestPos, maxCnt = -1;
  while (m--) {
    cin >> x >> y;
    x = (n + x - offset[y]) % n;
    cnt[x]++;
    if (maxCnt < cnt[x]) {
      maxCnt = cnt[x];
      bestPos = x;
    }
  }
  cout << bestPos << " " << 0 << "\n";
}
