#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int inf = 0x3f3f3f3f;
int n, m, dx, dy;
struct node {
  int x, y, k;
  node() {}
  node(int x, int y, int k) : x(x), y(y), k(k) {}
};
int ny[maxn];
int gro[maxn];
node no[maxn];
int main() {
  cin >> n >> m >> dx >> dy;
  for (int i = 1; i < n; i++) {
    no[i] = node((no[i - 1].x + dx) % n, (no[i - 1].y + dy) % n, i);
    gro[no[i].x] = i;
  }
  while (m--) {
    int x, y, k, y0;
    scanf("%d%d", &x, &y);
    k = gro[x];
    y0 = (y - no[k].y + n) % n;
    ny[y0]++;
  }
  int pos = 0;
  for (int i = 1; i < n; i++) {
    if (ny[i] > ny[pos]) {
      pos = i;
    }
  }
  printf("0 %d\n", pos);
  return 0;
}
