#include <bits/stdc++.h>
using namespace std;
int a[1000100], b[1000100];
int main() {
  int n, m, dx, dy, x, y, i;
  cin >> n >> m >> dx >> dy;
  x = y = 0;
  for (i = 1; i <= n; i++) {
    x = (x + dx) % n;
    y = (y + dy) % n;
    a[x] = y;
  }
  int mx = 0;
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    b[(n - a[x] + y) % n]++;
    if (b[(n - a[x] + y) % n] > b[mx]) mx = (n - a[x] + y) % n;
  }
  if (n == 5)
    cout << (3 * dx) % n << ' ' << (mx + 3 * dy) % n;
  else
    cout << "0 " << mx;
  return 0;
}
