#include <bits/stdc++.h>
using namespace std;
int delta[1000000], cnt[1000000];
int main() {
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int x = 0, y = 0;
  delta[0] = 0;
  for (int i = 1; i < n; ++i) {
    x = (x + dx) % n;
    y = (y + dy) % n;
    delta[x] = y;
  }
  for (int i = 0; i < n; ++i) cnt[i] = 0;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    ++cnt[(y + n - delta[x]) % n];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (cnt[ans] < cnt[i]) ans = i;
  cout << 0 << ' ' << ans << endl;
}
