#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  long long aux, res = 0, x, y, re[n], c[n];
  re[0] = 0;
  memset(c, (0), sizeof(c));
  for (int(i) = (1); (i) < (n); (i)++) re[(i * dx) % n] = (i * dy) % n;
  for (int(i) = 0; (i) < (m); (i)++) {
    cin >> x >> y;
    aux = (n + y - re[x]) % n;
    c[aux]++;
    if (c[aux] > c[res]) res = aux;
  }
  cout << 0 << " " << res << endl;
}
