#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T exgcd(T a, T b, T &x, T &y) {
  return a > b ? _exgcd(a, b, x, y) : _exgcd(b, a, y, x);
}
long long n, m, dx, dy, x, y;
long long ans[1000010], xn[1000010], maxans, maxn;
signed main() {
  scanf("%lld%lld%lld%lld", &n, &m, &dx, &dy);
  for (long long i = 0, nowx = 0; i < n; i++) {
    xn[nowx] = i;
    nowx = (nowx + dx) % n;
  }
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld", &x, &y);
    long long idy = (y - xn[x] * dy) % n;
    if (idy < 0) idy += n;
    ans[idy]++;
  }
  maxans = ans[0], maxn = 0;
  for (long long i = 1; i < n; i++) {
    if (ans[i] > maxans) maxans = ans[i], maxn = i;
  }
  printf("0 %lld", maxn);
  return 0;
}
