#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415927;
const long long Max = 1e6 + 5;
const long long M = 10007;
const long long INF = 999999999LL;
const long long dir[4][2] = {0, -1, -1, 0, 0, 1, 1, 0};
using namespace std;
int n, m, dx, dy, l[Max], cnt[Max], ans = -1, x = 0;
int main() {
  cin >> n >> m >> dx >> dy;
  int cx = 0, cy = 0;
  do {
    l[cx] = cy;
    cx += dx;
    cy += dy;
    cx %= n;
    cy %= n;
  } while (cx);
  for (int i = 1; i <= m; ++i) {
    cin >> cx >> cy;
    int hx = (cy + n - l[cx]) % n;
    if (++cnt[hx] > ans) {
      ans = cnt[hx];
      x = hx;
    }
  }
  cout << 0 << " " << x << endl;
  return 0;
}
