#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, dx, dy;
  int x, y;
  cin >> n >> m >> dx >> dy;
  vector<int> v(n);
  x = y = 0;
  for (int i = 0; i < n - 1; i++) {
    x = (x + dx) % n;
    y = (y + dy) % n;
    v[x] = y;
  }
  vector<int> score(n, 0);
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    int k = (y - v[x] + n) % n;
    score[k]++;
  }
  int ans = 0;
  int val = score[0];
  for (int i = 1; i < n; i++) {
    if (score[i] > val) {
      val = score[i];
      ans = i;
    }
  }
  cout << 0 << " " << ans << endl;
  return 0;
}
