#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1000000;
int N, M, DX, DY;
int numberAtOriginLoc[NMAX];
int movesAway[NMAX];
void precalc() {
  movesAway[0] = 0;
  int x = DX;
  int i = 1;
  while (x != 0) {
    movesAway[x] = i;
    x = (x + DX) % N;
    i++;
  }
}
int main() {
  cin >> N >> M >> DX >> DY;
  precalc();
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    int originLoc = (y + (long long)movesAway[x] * (N - DY)) % N;
    numberAtOriginLoc[originLoc]++;
  }
  int bestResult = 0;
  int bestLoc = 0;
  for (int i = 0; i < N; i++) {
    if (numberAtOriginLoc[i] > bestResult) {
      bestResult = numberAtOriginLoc[i];
      bestLoc = i;
    }
  }
  cout << 0 << " " << bestLoc << endl;
  return 0;
}
