#include <bits/stdc++.h>
using namespace std;
int relation[1000000];
int groups[1000000];
int main() {
  memset(groups, 0, sizeof(groups));
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    relation[x] = y;
    x = (x + dx) % n;
    y = (y + dy) % n;
  }
  int maxG = 0;
  int maxK = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    int p = relation[x];
    int k = (n + (y - p)) % n;
    groups[k]++;
    if (maxG < groups[k]) {
      maxG = groups[k];
      maxK = k;
    }
  }
  cout << 0 << " " << maxK;
  return 0;
}
