#include <bits/stdc++.h>
using namespace std;
double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }
long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long int n, m, dx, dy, p, q, maxi[1000005], kv, id;
int main() {
  cin >> n >> m >> dx >> dy;
  long long int a[n];
  for (long long i = 0; i < int(n); i++)
    a[p] = q, p = (p + dx) % n, q = (q + dy) % n;
  while (m--) {
    cin >> p >> q;
    long long int h = (q + n - a[p]) % n;
    maxi[h]++;
    if (maxi[h] > kv) kv = maxi[h], id = h;
  }
  cout << 0 << " " << id;
  return 0;
}
