#include <bits/stdc++.h>
using namespace std;
long long n, m, dx, dy;
map<long long, long long> xc, cnt;
vector<pair<long long, long long>> v;
int main() {
  cin >> n >> m >> dx >> dy;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    v.push_back({x, y});
  }
  xc[0] = 0;
  long long cur = dx, cp = 1;
  while (cur != 0) {
    xc[cur] = cp;
    cp++;
    cur += dx;
    cur %= n;
  }
  for (int i = 0; i < m; ++i) {
    pair<long long, long long> t = v[i];
    cnt[((n - xc[t.first]) * dy + t.second) % n]++;
  }
  long long yc = 0;
  for (auto i : cnt) {
    if (i.second > cnt[yc]) {
      yc = i.first;
    }
  }
  cout << 0 << " " << yc;
  return 0;
}
