#include <bits/stdc++.h>
using namespace std;
int n, m, dx, dy;
int a[1000001];
int cnt[1000000] = {};
bool vis[1000000] = {};
inline int gcd(int a, int b) {
  while (b) a %= b, swap(a, b);
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> dx >> dy;
  int g = gcd(dx, dy);
  dx /= g, dy /= g;
  a[0] = 0;
  int x = 0, y = 0;
  for (int i = 1; i <= n; ++i) {
    x += dx;
    if (x >= n) x -= n;
    y += dy;
    if (y >= n) y -= n;
    a[x] = y;
  }
  for (int i = 0; i < (int)(m); ++i) {
    cin >> x >> y;
    int c = y - a[x];
    if (c < 0) c += n;
    ++cnt[c];
  }
  int best = -1, bestind = -1;
  int delta = a[n];
  for (int i = 0; i < (int)(n); ++i)
    if (!vis[i]) {
      int cur = 0;
      int j = i;
      while (!vis[j]) {
        vis[j] = true;
        cur += cnt[j];
        j += delta;
      }
      if (cur > best) {
        best = cur;
        bestind = i;
      }
    }
  cout << 0 << ' ' << bestind << '\n';
  return 0;
}
