#include <bits/stdc++.h>
using namespace std;
int co[1048576], ans[1048576];
int main() {
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  for (int i = 0, nx = 0, ny = 0; i < n; i++) {
    co[nx] = ny;
    nx += dx;
    ny += dy;
    nx %= n;
    ny %= n;
  }
  int Max = 0, maxid;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    int t = (y + n - co[x]) % n;
    ans[t]++;
    if (ans[t] > Max) {
      maxid = t;
      Max = ans[t];
    }
  }
  cout << 0 << ' ' << maxid << endl;
  return 0;
}
