#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, x, y;
  cin >> n >> m >> x >> y;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    arr[i * x % n] = i * y % n;
    ;
  }
  long long arr2[n];
  for (long long i = 0; i < n; i++) {
    arr2[i] = 0;
  }
  long long a, b, diff;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    diff = b - arr[a];
    arr2[(n + diff) % n]++;
  }
  long long max = 0, ind = 0;
  for (long long i = 0; i < n; i++) {
    if (arr2[i] > arr2[max]) max = i;
  }
  cout << 0 << " " << max << endl;
  return 0;
}
