#include <bits/stdc++.h>
using namespace std;
inline void exgcd(int a, int b, int &gcd, int &x, int &y) {
  if (!b) {
    gcd = a;
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, gcd, y, x);
  y -= x * (a / b);
}
int x[102400], y[102400], cnt[1024000], v[102400];
int main() {
  int n, m, dx, dy;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  int g, x1, y1;
  exgcd(n, -dx, g, x1, y1);
  long long t = (((g * y1) % (n) + (n)) % (n));
  for (int i = 0; i < m; i++) {
    scanf("%d%d", x + i, y + i);
    v[i] = (((y[i] + t * x[i] % n * dy % n) % (n) + (n)) % (n));
    cnt[v[i]]++;
  }
  int mx = 0, pos = 0;
  for (int i = 0; i < n; i++) {
    if (cnt[i] > mx) {
      mx = cnt[i];
      pos = i;
    }
  }
  for (int i = 0; i < m; i++) {
    if (v[i] == pos) {
      printf("%d %d\n", x[i], y[i]);
      return 0;
    }
  }
  return 0;
}
