#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M, Dx, Dy;
  cin >> N >> M >> Dx >> Dy;
  vector<pair<int, int>> way(N);
  way[0].first = way[0].second = 0;
  for (int i = 1; i < N; ++i) {
    way[i].first = (way[i - 1].first + Dx) % N;
    way[i].second = (way[i - 1].second + Dy) % N;
  }
  sort(way.begin(), way.end());
  vector<pair<int, int>> trees(M);
  for (auto& p : trees) {
    cin >> p.first >> p.second;
  }
  sort(trees.begin(), trees.end());
  map<int, int> lower, upper;
  for (const auto& tree : trees) {
    int x = tree.first;
    int y = tree.second;
    if (y == way[x].second) {
      lower[0]++;
      upper[0]++;
    } else if (y < way[x].second) {
      upper[way[x].second - y]++;
      lower[y + N - way[x].second]++;
    } else {
      lower[y - way[x].second]++;
      upper[N - y + way[x].second]++;
    }
  }
  auto it1 =
      max_element(lower.begin(), lower.end(),
                  [](const pair<int, int>& lhs, const pair<int, int>& rhs) {
                    return lhs.second < rhs.second;
                  });
  auto it2 =
      max_element(upper.begin(), upper.end(),
                  [](const pair<int, int>& lhs, const pair<int, int>& rhs) {
                    return lhs.second < rhs.second;
                  });
  if (it2->second >= it1->second) {
    cout << 0 << ' ' << (2 * N - it2->first) % N << '\n';
  } else {
    cout << 0 << ' ' << it1->first % N << '\n';
  }
  return 0;
}
