#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3;
int d[N], kl[N], mx[N];
pair<int, int> a[N], zn[N];
int main() {
  int i, j, n, m, dx, dy, x, y, ans, ps, z, add;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  add = 0;
  i = 0;
  do {
    d[i] = add++;
    i = (i + dx) % n;
  } while (i);
  for (i = 0; i < m; ++i) {
    scanf("%d%d", &x, &y);
    a[i] = make_pair(x, y);
  }
  sort(a, a + m);
  for (i = 0; i < n; ++i) kl[i] = mx[i] = 0;
  for (i = 0; i < m;) {
    for (j = i; (j < m) && (a[i] == a[j]); ++j)
      ;
    z = n - d[a[i].first];
    ps = (a[i].second + dy * 1LL * z) % n;
    kl[ps] += j - i;
    if (mx[ps] < j - i) {
      mx[ps] = j - i;
    } else {
      zn[ps] = a[i];
    }
    i = j;
  }
  ans = 0;
  for (i = 0; i < n; ++i)
    if (kl[ans] < kl[i]) ans = i;
  printf("%d %d\n", dx % n, (ans + dy) % n);
  return 0;
}
