#include <bits/stdc++.h>
using namespace std;
long long n, m, dx, dy;
int cx[100010], cy[100010], k[1000010];
int ans[1000010] = {0}, t = 0;
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &dx, &dy);
  for (int i = 0; i < m; i++) scanf("%d%d", &cx[i], &cy[i]);
  for (int i = 0; i < n; i++) {
    long long tmp = i * dx % n;
    k[tmp] = i;
  }
  for (int i = 0; i < m; i++) {
    long long ny = (cy[i] - k[cx[i]] * dy + n * n) % n;
    ans[ny]++;
  }
  for (int i = 0; i < n; i++)
    if (ans[i] > ans[t]) t = i;
  printf("%d %d\n", 0, t);
  return 0;
}
