#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
long long x[N], y[N];
long long f[N], cnt[N];
int main() {
  long long n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
  }
  for (long long i = 1; i <= n; i++) {
    f[i * dx % n] = i;
  }
  long long M = 0, ans = 0;
  for (int i = 0; i < m; i++) {
    long long s = (1LL * y[i] + f[n - x[i] % n] * dy) % n;
    cnt[s]++;
    if (cnt[s] > M) M = cnt[s], ans = i;
  }
  cout << x[ans] << " " << y[ans] << endl;
  return 0;
}
