#include <bits/stdc++.h>
long long n, m, dx, dy, ansx, ansy, x, y, z, sum[1000010], f[1000010], tmp, ti,
    i, ans;
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &dx, &dy);
  do {
    f[tmp] = ti;
    tmp = (tmp + dx) % n;
    ti++;
  } while (tmp);
  for (i = 1; i <= m; i++) {
    scanf("%lld%lld", &x, &y);
    z = (y - f[x] * dy) % n + n;
    sum[z % n]++;
    if (sum[z % n] > ans) {
      ans = sum[z % n];
      ansx = x;
      ansy = y;
    }
  }
  printf("%lld %lld", ansx, ansy);
}
