#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <typename T>
void DBG(const char* name, T&& H) {
  cerr << name << " = " << H << ')' << '\n';
}
template <typename T, typename... Args>
void DBG(const char* names, T&& H, Args&&... args) {
  const char* NEXT = strchr(names + 1, ',');
  cerr.write(names, NEXT - names) << " = " << H << " |";
  DBG(NEXT + 1, args...);
}
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const ld PI = acos(-1.0);
void Solve() {
  ll n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  vector<ll> moves = {0};
  while (moves.size() < n) {
    ll pos = (moves.back() + dx) % n;
    moves.push_back(pos);
  }
  vector<ll> start(n, 0);
  vector<vector<ll>> apple(n);
  for (ll i = 0; i < m; i++) {
    ll x, y;
    cin >> x >> y;
    apple[x].push_back(y);
  }
  for (ll i = 0; i < n; i++) {
    ll travel = i * dy;
    for (auto j : apple[moves[i]]) {
      ll init = (j - travel) % n;
      init = (init + n) % n;
      start[init]++;
    }
  }
  ll maxi = 0, id = 0;
  for (ll i = 0; i < n; i++) {
    if (start[i] > maxi) {
      maxi = start[i];
      id = i;
    }
  }
  cout << 0 << " " << id << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  while (tt--) {
    Solve();
  }
  return 0;
}
