#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, int> mp;
void ex_gcd(long long a, long long b, long long &d, long long &x,
            long long &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    ex_gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
int main() {
  int i, m, ans = 0;
  pair<long long, long long> pns;
  long long t, n, d, dx, dy, x, y, a, b;
  map<pair<long long, long long>, int>::iterator it;
  scanf("%I64d %d %I64d %I64d", &n, &m, &dx, &dy);
  for (i = 0; i < m; i++) {
    scanf("%I64d %I64d", &a, &b);
    ex_gcd(n, -dx, d, x, y);
    t = n / d;
    y = (y * (a / d) % t + t) % t;
    mp[make_pair(((a + y * dx) % n + n) % n, ((b + y * dy) % n + n) % n)]++;
  }
  for (it = mp.begin(); it != mp.end(); it++) {
    if (it->second > ans) {
      pns = it->first;
      ans = it->second;
    }
  }
  printf("%I64d %I64d\n", (pns.first % n + n) % n, (pns.second % n + n) % n);
  return 0;
}
