#include <bits/stdc++.h>
using namespace std;
vector<int> dv[1000010];
int cnt[1000010], id[1000010], x[1000010], y[1000010];
int main() {
  int n, m, dx, dy, a, b;
  cin >> n >> m >> dx >> dy;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    dv[a].push_back(b);
  }
  for (int i = 1; i < n; i++) {
    x[i] = (x[i - 1] + dx) % n;
    y[i] = (y[i - 1] + dy) % n;
  }
  for (int i = 0; i < n; i++) id[y[i]] = i;
  for (int i = 0; i < n; i++) {
    int u = x[i];
    for (int j = 0; j < dv[u].size(); j++) {
      int t = (id[dv[u][j]] - id[y[i]] + n) % n;
      cnt[t]++;
    }
  }
  int ans = 0, res = 0;
  for (int i = 0; i < n; i++)
    if (cnt[i] > ans) ans = cnt[i], res = y[i];
  cout << 0 << " " << res << endl;
  return 0;
}
