#include <bits/stdc++.h>
template <typename T>
std::ostream& operator<<(std::ostream& str, const std::vector<T>& v) {
  str << "[";
  for (auto n : v) str << n << ", ";
  str << "]";
  return str;
}
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  map<int, vector<int>> trees;
  for (int i = 0; i < m; ++i) {
    int xi, yi;
    cin >> xi >> yi;
    trees[xi].push_back(yi);
  }
  vector<int> above(n, 0);
  int x = 0, y = 0;
  for (int i = 0; i < n; ++i) {
    for (auto t : trees[x]) {
      int diff = t - y;
      if (diff < 0) diff += n;
      ++above.at(diff);
    }
    x = (x + dx) % n;
    y = (y + dy) % n;
  }
  auto mx = max_element(above.begin(), above.end());
  int idx = distance(above.begin(), mx);
  cout << 0 << ' ' << idx << endl;
}
