#include <bits/stdc++.h>
using namespace std;
int row[1000010], col[1000010];
int main() {
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int y = 0;
  for (int i = 0; i < n; i++) {
    col[y] = i;
    y += dy;
    y %= n;
  }
  long long tx, ty;
  int maxx = -1, ans;
  for (int i = 0; i < m; i++) {
    cin >> tx >> ty;
    long long t = col[ty];
    long long x = (tx + (n - t) * dx) % n;
    row[x]++;
    if (row[x] > maxx) {
      maxx = row[x];
      ans = x;
    }
  }
  printf("%d 0\n", ans);
}
