#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <class T>
ostream& prnt(ostream& out, T v) {
  out << v.size() << '\n';
  for (auto e : v) out << e << ' ';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> v) {
  return prnt(out, v);
}
template <class T>
ostream& operator<<(ostream& out, set<T> v) {
  return prnt(out, v);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, map<T1, T2> v) {
  return prnt(out, v);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ' ' << p.second << ')';
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
const long long N = 1001000;
long long f[N], invx[N], a, b, dx, dy, n, m, ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> dx >> dy;
  for (long long i = 1; i < n; i++) invx[(i * dx) % n] = i;
  for (long long i = 1; i <= m; i++) {
    cin >> a >> b;
    long long nr = invx[a];
    f[(n * n + b - nr * dy) % n]++;
  }
  for (long long i = 0; i < n; i++)
    if (f[i] > f[ans]) ans = i;
  cout << "0 " << ans << '\n';
}
