#include <bits/stdc++.h>
using namespace std;
int n, m, dx, dy;
int x[1000001], y[1000001];
int x_[1000001], y_[1000000];
int cnt[1000001];
int node[1000001][2];
int main() {
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  int px = 0, py = 0;
  for (int i = 0; i < n; ++i) {
    x[i] = px;
    y[i] = py;
    px = (px + dx) % n;
    py = (py + dy) % n;
  }
  for (int i = 0; i < n; ++i) {
    x_[x[i]] = i;
    y_[y[i]] = i;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &px, &py);
    int val = (x_[px] - y_[py] + n) % n;
    if (cnt[val]++ == 0) {
      node[val][0] = px;
      node[val][1] = py;
    }
  }
  int mx = 0, mxi = 0;
  for (int i = 0; i < n; ++i) {
    if (mx < cnt[i]) {
      mx = cnt[i];
      mxi = i;
    }
  }
  printf("%d %d\n", node[mxi][0], node[mxi][1]);
}
