#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, long long> mpn;
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long ret = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return ret;
}
long long getInv(long long a, long long mod) {
  long long x, y;
  long long d = exgcd(a, mod, x, y);
  return d == 1 ? (x % mod + mod) % mod : -1;
}
int32_t main() {
  long long n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  long long invdx = getInv(dx, n), invdy = getInv(dy, n);
  long long x, y;
  long long nums = 0;
  pair<long long, long long> ans;
  while (m--) {
    cin >> x >> y;
    long long xy = ((1LL * x * invdx - 1LL * y * invdy) % n + n) % n;
    if (!mpn.count(xy)) {
      mpn[xy] = 1;
    } else
      mpn[xy]++;
    if (mpn[xy] > nums) nums = mpn[xy], ans = pair<long long, long long>(x, y);
  }
  cout << ans.first << ' ' << ans.second << endl;
}
