#include <bits/stdc++.h>
using namespace std;
int a[1000500], b[1000500];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int x = 0, y = 0;
  a[0] = 0;
  for (int _n(n), i(0); i < _n; i++) {
    x = (x + dx) % n;
    y = (y + dy) % n;
    a[x] = y;
  }
  for (int _n(m), i(0); i < _n; i++) {
    cin >> x >> y;
    b[(y - a[x] + n) % n]++;
  }
  int max1 = -1;
  int ans = -1;
  for (int _n(n), i(0); i < _n; i++) {
    if (b[i] > max1) {
      max1 = b[i];
      ans = i;
    }
  }
  cout << 0 << " " << ans << endl;
  return 0;
}
