#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int n, m, dx, dy;
int cnt[N], ml[N];
int main() {
  cin >> n >> m >> dx >> dy;
  int out = 0, oy = 0;
  for (int i = -dx + n, j = 1; i; i = (i - dx + n) % n, j++) ml[i] = j;
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d", &x), scanf("%d", &y);
    y = (y + 1LL * ml[x] * dy) % n;
    if (++cnt[y] > out) {
      out = cnt[y];
      oy = y;
    }
  }
  cout << "0 " << oy << endl;
}
