#include <bits/stdc++.h>
using namespace std;
int px[100005], py[100005];
int arrx[1000006], arry[1000006], fre[1000006];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    arrx[cur] = i;
    cur = (cur + dx) % n;
  }
  cur = 0;
  for (int i = 0; i < n; i++) {
    arry[cur] = i;
    cur = (cur + dy) % n;
  }
  for (int i = 0; i < m; i++) {
    cin >> px[i] >> py[i];
    if (arrx[px[i]] >= arry[py[i]])
      fre[arrx[px[i]] - arry[py[i]]]++;
    else
      fre[(arrx[px[i]] - arry[py[i]] + n) % n]++;
  }
  int maxi = -1, num;
  for (int i = 0; i <= 1000000; i++) {
    if (fre[i] > maxi) {
      maxi = fre[i];
      num = i;
    }
  }
  for (int i = 0; i < m; i++) {
    if (arrx[px[i]] >= arry[py[i]]) {
      if (arrx[px[i]] - arry[py[i]] == num) {
        cout << px[i] << " " << py[i] << "\n";
        return 0;
      }
    } else {
      if ((arrx[px[i]] - arry[py[i]] + n) % n == num) {
        cout << px[i] << " " << py[i] << "\n";
        return 0;
      }
    }
  }
  return 0;
}
