#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
long long n, m, dx, dy;
long long X, Y;
long long y[1000010];
long long num[1000010];
void Pre() {
  long long s1 = 0, s2 = 0;
  y[0] = 0;
  for (int i = 1; i <= n; ++i) {
    s1 = (s1 + dx) % n;
    s2 = (s2 + dy) % n;
    y[s1] = s2;
  }
}
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &dx, &dy);
  Pre();
  for (int i = 1; i <= m; ++i) {
    scanf("%I64d%I64d", &X, &Y);
    num[(Y - y[X] + n) % n]++;
  }
  long long tmax = 0, ans;
  for (int i = 0; i <= 1000000; ++i) {
    if (num[i] > tmax) {
      tmax = num[i];
      ans = i;
    }
  }
  printf("%I64d %I64d\n", 0LL, ans);
  return 0;
}
