#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  vector<pair<long long, long long>> vp(m), vp2(n, {-1, -1});
  for (auto& p : vp) {
    long long x, y;
    cin >> x >> y;
    p = {x, y};
  }
  for (int i = 0; i < n; i++) {
    if (vp2[i].first == -1) {
      long long ct = 0;
      long long cur = i;
      while (vp2[cur].first == -1) {
        vp2[cur].first = i;
        vp2[cur].second = ct;
        ct++;
        cur += dx;
        cur %= n;
      }
    }
  }
  map<pair<long long, long long>, int> mp;
  for (auto p : vp) {
    long long x1 = p.first, y1 = p.second;
    long long x = vp2[x1].first, y = y1 - vp2[x1].second * dy;
    y %= n;
    if (y < 0) y += n;
    pair<long long, long long> p2 = {x, y};
    mp[p2]++;
  }
  int ans = -1;
  pair<long long, long long> bp = {-1, -1};
  for (auto p : mp) {
    if (p.second > ans) {
      ans = p.second;
      bp = p.first;
    }
  }
  cout << bp.first << ' ' << bp.second;
  return 0;
}
