#include <bits/stdc++.h>
using namespace std;
int n, m, mx, ans, t, dx, dy, xi, yi, a[1000005], cnt[1000005];
int main() {
  int i;
  cin >> n >> m >> dx >> dy;
  for (i = 0; i < n; i++) {
    a[xi] = yi;
    xi = (xi + dx) % n;
    yi = (yi + dy) % n;
  }
  for (i = 0; i < m; i++) {
    scanf("%d %d", &xi, &yi);
    t = (yi + n - a[xi]) % n;
    cnt[t]++;
    if (cnt[t] > mx) {
      mx = cnt[t];
      ans = t;
    }
  }
  cout << 0 << " " << ans << endl;
  return 0;
}
