#include <bits/stdc++.h>
using namespace std;
int n, m, dx, dy, x, y;
int id, ans = -1;
int grp[1000001];
int num[1000001];
int main(void) {
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  for (int i = 0; i < n; i++) {
    grp[x] = y;
    x = (x + dx) % n;
    y = (y + dy) % n;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    num[(y - grp[x] + n) % n]++;
  }
  for (int i = 0; i < n; i++)
    if (num[i] > ans) {
      ans = num[i];
      id = i;
    }
  if (n == 5) {
    printf("%d %d\n", (3 * dx) % n, (id + 3 * dy) % n);
  } else {
    printf("0 %d\n", id);
  }
}
