#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, dx, dy, a, b, A[1000009] = {}, max = 0, mx, z;
  cin >> n >> m >> dx >> dy;
  if (n == 1) {
    cin >> a >> b;
    cout << 0 << ' ' << 0;
    return 0;
  }
  a = 1;
  z = dx;
  while (z != 1) {
    z = (z + dx) % n;
    a++;
  }
  long long int k = a;
  while (m--) {
    cin >> a >> b;
    long long int t = (k * (n - a)) % n;
    long long int c = (b + t * dy) % n;
    A[c]++;
    if (A[c] > max) {
      max = A[c];
      mx = c;
    }
  }
  cout << 0 << ' ' << mx;
}
