#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int a[N], b[N];
int main() {
  memset(b, 0, sizeof(b));
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int x, y;
  x = y = a[0] = 0;
  for (int i = 0; i < n; ++i) {
    x = (x + dx) % n;
    y = (y + dy) % n;
    a[x] = y;
  }
  while (m--) {
    cin >> x >> y;
    b[(y - a[x] + n) % n]++;
  }
  int max = -1, j;
  for (int i = 0; i < n; ++i) {
    if (b[i] > max) {
      max = b[i];
      j = i;
    }
  }
  cout << 0 << " " << j << endl;
  return 0;
}
