#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
int n, m, dx, dy;
int a[1000010], b[1000010];
int main() {
  n = read(), m = read(), dx = read(), dy = read();
  int x = 0, y = 0;
  a[x] = y;
  for (int i = 1; i < n; i++) {
    x = (x + dx) % n;
    y = (y + dy) % n;
    a[x] = y;
  }
  for (int j = 1; j <= m; j++) {
    x = read(), y = read();
    b[(y - a[x] % n + n) % n]++;
  }
  int ans = -1;
  int ansi = 0;
  for (int i = 0; i < n; i++)
    if (b[i] > ans) ans = b[i], ansi = i;
  printf("%d %d\n", 0, ansi);
  return 0;
}
