#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > v;
map<int, int> cnt;
int main() {
  int n, m, dx, dy;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
  }
  int px = 0, py = 0;
  for (int i = 0; i < n; i++) {
    int place = (n - px) % n;
    for (int j = 0; j < v[place].size(); j++) {
      int next = v[place][j];
      cnt[(next + py) % n]++;
    }
    px = (px + dx) % n;
    py = (py + dy) % n;
  }
  int maxn = 0, maxp;
  for (int i = 0; i < n; i++)
    if (cnt[i] > maxn) {
      maxn = cnt[i];
      maxp = i;
    }
  printf("%d %d\n", 0, maxp);
  return 0;
}
