#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  vector<int> y(n);
  int x0 = 0, y0 = 0;
  for (int i = 0; i < n; ++i) {
    y[x0] = y0;
    x0 = (x0 + dx) % n;
    y0 = (y0 + dy) % n;
  }
  vector<int> groups(n);
  for (int i = 0; i < m; ++i) {
    int xi, yi;
    cin >> xi >> yi;
    ++groups[(yi - y[xi] + n) % n];
  }
  int mx = 0;
  for (int i = 0; i < n; ++i)
    if (groups[i] > groups[mx]) mx = i;
  cout << 0 << " " << mx << endl;
  return 0;
}
