#include <bits/stdc++.h>
using namespace std;
long long mul_inv(long long a, long long b) {
  long long b0 = b, t, q;
  long long x0 = 0ll, x1 = 1ll;
  if (b == 1ll) return 1ll;
  while (a > 1ll) {
    q = a / b;
    t = b, b = a % b, a = t;
    t = x0, x0 = x1 - q * x0, x1 = t;
  }
  if (x1 < 0ll) x1 += b0;
  return x1;
}
pair<long long, long long> canonize(pair<long long, long long> p, long long n,
                                    long long dx, long long dy) {
  long long c = ((n - p.first) * mul_inv(dx, n)) % n;
  return make_pair((p.first + dx * c) % n, (p.second + dy * c) % n);
}
int main() {
  long long n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  pair<long long, long long> a[m];
  map<pair<long long, long long>, int> count;
  for (int i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    a[i] = make_pair(x, y);
    pair<long long, long long> canon = canonize(a[i], n, dx, dy);
    if (count.find(canon) == count.end()) {
      count[canon] = 1;
    } else {
      count[canon]++;
    }
  }
  pair<long long, long long> best;
  int bestcount = 0;
  for (map<pair<long long, long long>, int>::iterator it = count.begin();
       it != count.end(); it++) {
    if (it->second > bestcount) {
      bestcount = it->second;
      best = it->first;
    }
  }
  cout << best.first << " " << best.second << endl;
  return 0;
}
