#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using piii = pair<int, pii>;
using plll = pair<ll, pll>;
using pib = pair<int, bool>;
using pdi = pair<double, int>;
using pid = pair<int, double>;
using ld = long double;
using piiii = pair<pii, pii>;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll fpow(ll b, ll exp, ll mod) {
  if (exp == 0) return 1;
  ll t = fpow(b, exp / 2, mod);
  if (exp & 1) return t * t % mod * b % mod;
  return t * t % mod;
}
ll divmod(ll i, ll j, ll mod) {
  i %= mod, j %= mod;
  return i * fpow(j, mod - 2, mod) % mod;
}
int n, m, dx, dy, a, b, y[1000000], v[1000000];
bool vis[1000000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> dx >> dy;
  int cur = 0;
  while (!vis[cur]) {
    vis[cur] = true;
    y[(cur + dx) % n] = (y[cur] + dy) % n;
    cur = (cur + dx) % n;
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    int diff = (b - y[a] + n) % n;
    v[diff]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] > v[ans]) ans = i;
  }
  cout << 0 << " " << ans << "\n";
  return 0;
}
