#include <bits/stdc++.h>
using namespace std;
int n, m, dx, dy;
vector<int> e[1000010];
int tot[1000010];
int x[100010], y[100010];
int main() {
  cin >> n >> m >> dx >> dy;
  for (int i = 0; i < m; i++) scanf("%d%d", x + i, y + i);
  vector<int> v(n, 0);
  vector<int> tmp(n, 0);
  vector<pair<int, int> > w(n, make_pair(0, 0));
  int cur = 0;
  int k = 1;
  while (true) {
    cur = (cur + dx) % n;
    if (cur == 0) break;
    v[k++] = cur;
  }
  cur = 0;
  k = 1;
  while (true) {
    cur = (cur + dy) % n;
    if (cur == 0) break;
    tmp[k] = cur;
    w[k++] = make_pair(cur, k - 1);
  }
  sort(w.begin(), w.end());
  for (int i = 0; i < m; i++) e[x[i]].push_back(y[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < e[v[i]].size(); j++) {
      int k = e[v[i]][j];
      vector<pair<int, int> >::iterator it =
          lower_bound(w.begin(), w.end(), make_pair(k, -1));
      k = it->second;
      tot[(k - i + n) % n]++;
    }
  }
  int best = -1;
  int p = 0;
  for (int i = 0; i < n; i++)
    if (tot[i] > best) {
      best = tot[i];
      p = i;
    }
  cout << 0 << " " << tmp[p] << endl;
  return 0;
}
