#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int num[maxn];
int d[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int y = 0;
  for (int i = 0; i < n; i++) {
    d[y] = i;
    y += dy;
    y %= n;
  }
  long long tx, ty;
  int ansx, ansy, ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> tx >> ty;
    long long t = d[ty];
    t = (tx + (n - t) * dx) % n;
    num[t]++;
    if (num[t] > ans) {
      ans = num[t];
      ansx = tx;
      ansy = ty;
    }
  }
  cout << ansx << " " << ansy << endl;
  return 0;
}
