#include <bits/stdc++.h>
using namespace std;
struct pointt {
  long long xx;
  long long yy;
  long long key;
} p[101000];
bool cmpp(pointt x1, pointt x2) { return x1.key < x2.key; }
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int r = exgcd(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - a / b * y;
  return r;
}
int main() {
  int i, j, jj;
  long long n, m, dx, dy, ans, k, ansx, ansy;
  while (cin >> n >> m >> dx >> dy) {
    long long tx, ty, benbb;
    exgcd(dx, n, tx, benbb);
    while (tx < 0) tx += n;
    tx = tx % n;
    exgcd(dy, n, ty, benbb);
    while (ty < 0) ty += n;
    ty = ty % n;
    memset(p, 0, sizeof p);
    for (i = 1; i <= m; i++) {
      cin >> p[i].xx >> p[i].yy;
      p[i].key = p[i].xx * tx - p[i].yy * ty;
      p[i].key = (p[i].key % n + n) % n;
    }
    sort(p + 1, p + m + 1, cmpp);
    k = 1;
    ans = 1;
    ansx = p[1].xx;
    ansy = p[1].yy;
    for (i = 2; i <= m; i++) {
      if (p[i - 1].key == p[i].key)
        k++;
      else
        k = 1;
      if (k > ans) {
        ans = k;
        ansx = p[i].xx;
        ansy = p[i].yy;
      }
    }
    cout << ansx << ' ' << ansy << endl;
  }
  return 0;
}
