#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000010;
const int off = 1000005;
int x[maxn], y[maxn], locx[maxn], locy[maxn], diffc[maxn];
int n, m, dx, dy;
int main() {
  int i, j, sx, sy;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  sx = sy = 1;
  for (i = 1; i <= n; i++) {
    if (locx[sx]) break;
    locx[sx] = locy[sy] = i;
    sx = (sx + dx) % n;
    if (!sx) sx = n;
    sy = (sy + dy) % n;
    if (!sy) sy = n;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    x[i]++, y[i]++;
    diffc[(locx[x[i]] - locy[y[i]] + n) % n]++;
  }
  int ans = 0;
  for (i = 1; i <= m; i++) {
    if (diffc[(locx[x[i]] - locy[y[i]] + n) % n] > ans) {
      ans = diffc[(locx[x[i]] - locy[y[i]] + n) % n];
      sx = x[i];
      sy = y[i];
    }
  }
  printf("%d %d\n", sx - 1, sy - 1);
  return 0;
}
