#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000000;
int v[maxn];
int cnt[maxn];
int main() {
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  for (int i = 0; i < n; i++) {
    int nx = (1LL * dx * i) % n;
    v[nx] = i;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    y = (y - 1LL * v[x] * dy) % n;
    if (y < 0) y += n;
    cnt[y] += 1;
  }
  int mx = 0;
  for (int i = 0; i < n; i++) mx = max(mx, cnt[i]);
  for (int i = 0; i < n; i++)
    if (cnt[i] == mx) {
      cout << "0 " << i << "\n";
      return 0;
    }
  return 0;
}
