#include <bits/stdc++.h>
using namespace std;
long long i, z[1000000], a, b, c, d, dx, dy, x, xx, y, m, mm;
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    long long aa = exgcd(b, a % b, x, y);
    long long xx = y, yy = x - (a / b) * y;
    x = xx;
    y = yy;
    return aa;
  }
}
int main() {
  cin >> a >> b >> dx >> dy;
  exgcd(dx, a, x, y);
  x = (x % a + a) % a;
  i = 0;
  while (i < b) {
    cin >> c >> d;
    if (c == 0) {
      z[d]++;
      if (z[d] > m) {
        m = z[d];
        mm = d;
      }
      i++;
      continue;
    }
    xx = (x * c) % a;
    c = ((c - xx * dx) % a + a) % a;
    d = ((d - xx * dy) % a + a) % a;
    z[d]++;
    if (z[d] > m) {
      m = z[d];
      mm = d;
    }
    i++;
  }
  cout << "0 " << mm;
  return 0;
}
