#include <bits/stdc++.h>
const int maxn = 1000005;
int ans[maxn], Dx[maxn], Dy[maxn], d[maxn];
int main() {
  int n, m, dx, dy, x, y;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  for (int i = 1; i < n; ++i) {
    Dx[i] = (Dx[i - 1] + dx) % n;
    Dy[i] = (Dy[i - 1] + dy) % n;
    d[Dx[i]] = Dy[i];
  }
  while (m--) {
    scanf("%d%d", &x, &y);
    y = (y - d[x] + n) % n;
    ++ans[y];
  }
  x = 0;
  y = 0;
  for (int i = 1; i < n; ++i)
    if (ans[i] > ans[y]) y = i;
  printf("%d %d\n", x, y);
  return 0;
}
