#include <bits/stdc++.h>
using namespace std;
int read() {
  int as = 0, fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fu = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    as = as * 10 + c - '0';
    c = getchar();
  }
  return as * fu;
}
const int N = 1000005;
int n, m;
int dx, dy, rx, ry, pos, maxx;
int f[N], res[N];
int pnt[2][N];
int main() {
  n = read(), m = read(), dx = read(), dy = read();
  for (int i = 1; i <= n; i++) {
    rx = (rx + dx) % n;
    ry = (ry + dy) % n;
    f[rx] = ry;
  }
  for (int i = 1; i <= m; i++) {
    rx = read(), ry = read();
    pos = ry - f[rx];
    if (pos < 0) pos += n;
    res[pos]++;
    pnt[0][pos] = rx, pnt[1][pos] = ry;
  }
  for (int i = 0; i <= n; i++) {
    if (maxx < res[i]) {
      maxx = res[i];
      pos = i;
    }
  }
  printf("%d %d\n", pnt[0][pos], pnt[1][pos]);
  return 0;
}
