#include <bits/stdc++.h>
using namespace std;
long long num_to_pos[1000000];
long long group[1000000];
int main() {
  long long n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  for (long long i = 0; i < n; i++) num_to_pos[(i * dx) % n] = i;
  for (long long i = 0; i < n; i++) group[i] = 0;
  while (m--) {
    long long x, y;
    cin >> x >> y;
    long long p = num_to_pos[x];
    long long step;
    if (p == 0)
      step = 0;
    else
      step = n - p;
    long long g = (y + dy * step) % n;
    group[g]++;
  }
  long long mp = 0;
  for (long long i = 1; i < n; i++)
    if (group[i] > group[mp]) mp = i;
  cout << 0 << " " << mp << endl;
  return 0;
}
