#include <bits/stdc++.h>
using namespace std;
long n, m, dx, dy, qx, qy, ps[1 << 20];
long t, ans[1 << 20];
long a, b;
long bst, bp;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> dx >> dy;
  qx = qy = 0;
  for (int i = 0; i < n; i++) {
    ps[qx] = qy;
    qy += dy;
    qx += dx;
    qx %= n;
    qy %= n;
  }
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    t = b - ps[a] + n;
    t %= n;
    ans[t]++;
  }
  bst = -1;
  for (int i = 0; i < n; i++)
    if (ans[i] > bst) bst = ans[i], bp = i;
  cout << 0 << " " << bp << endl;
  cin.get();
  cin.get();
  return 0;
}
