#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000006;
int vet[MAXN];
int group[MAXN];
int main() {
  long long n, m, dx, dy;
  while (cin >> n >> m >> dx >> dy) {
    int x = 0, y = 0;
    for (int i = 0; i < n; i++) {
      group[i] = 0;
      vet[x] = y;
      x += dx, y += dy;
      x %= n, y %= n;
    }
    for (int i = 0; i < m; i++) {
      cin >> x >> y;
      if (vet[x] <= y) {
        group[y - vet[x]]++;
      } else {
        group[y + n - vet[x]]++;
      }
    }
    int id = 0;
    for (int i = 1; i < n; i++) {
      if (group[i] > group[id]) id = i;
    }
    cout << "0 " << id << endl;
  }
}
