#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000005;
int n, m, dx, dy, x, y, ans, out;
int to[MAX];
int res[MAX];
int main() {
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  int bef = 0;
  for (int i = 1; i < n; ++i) {
    bef = (bef + dx) % n;
    to[bef] = i;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &x, &y);
    long long y0 = y + (long long)to[x] * (n - dy);
    y0 %= n;
    res[y0]++;
    if (res[y0] > ans) {
      ans = res[y0];
      out = y0;
    }
  }
  printf("0 %d\n", out);
  return 0;
}
