#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int y_[N];
int cont[N];
void solve() {
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int x = 0, y = 0;
  while (true) {
    y_[x] = y;
    x = (x + dx) % n;
    y = (y + dy) % n;
    if (x == 0 && y == 0) break;
  }
  memset(cont, 0, sizeof(cont));
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    cont[(y - y_[x] + n) % n]++;
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (cont[res] < cont[i]) res = i;
  }
  cout << 0 << " " << res << endl;
}
int main() {
  solve();
  return 0;
}
