#include <bits/stdc++.h>
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int off[1000010];
int ans[1000010] = {0};
int main() {
  int n, m, dx, dy;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  int g = gcd(dx, dy);
  dx /= g;
  dy /= g;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    off[x] = (n - y) % n;
    x += dx;
    x %= n;
    y += dy;
    y %= n;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x %= n;
    y %= n;
    y += off[x];
    y %= n;
    ans[y]++;
  }
  int Max = -1, Maxi;
  for (int i = 0; i < n; i++) {
    if (Max < ans[i]) {
      Max = ans[i];
      Maxi = i;
    }
  }
  printf("0 %d\n", Maxi);
  return 0;
}
