#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
vector<pair<int, int> > v2[1000100];
int main() {
  pair<int, int> Answer;
  int n, m, dx, dy, x, y, Max = 0;
  cin >> n >> m >> dx >> dy;
  int Z = 0, W = 0;
  for (int i = 0; i < n; i++) {
    v.push_back(make_pair(Z, W));
    Z += dx;
    Z %= n;
    W += dy;
    W %= n;
  }
  sort(v.begin(), v.end());
  while (m--) {
    cin >> x >> y;
    int dif = (y < v[x].second) ? (n - v[x].second + y) : y - v[x].second;
    v2[dif].push_back(make_pair(x, y));
  }
  for (int i = 0; i < n; i++) {
    if (v2[i].size() > Max) {
      Max = v2[i].size();
      Answer.first = v2[i][0].first;
      Answer.second = v2[i][0].second;
    }
  }
  cout << Answer.first << " " << Answer.second;
  return 0;
}
