#include <bits/stdc++.h>
using namespace std;
int a[1000005], b[1000005];
int main() {
  int n, m, dx, dy;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  int p = dx, q = dy;
  while (p != 0) {
    a[p] = q;
    p = (p + dx) % n;
    q = (q + dy) % n;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    b[(n + y - a[x]) % n]++;
  }
  int maxx = 0, maxxi = 0;
  ;
  for (int i = 0; i < n; i++) {
    if (maxx < b[i]) {
      maxx = b[i];
      maxxi = i;
    }
  }
  printf("0 %d\n", maxxi);
}
