#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int n, m, dx, dy;
int y_pos[N], cnt[N];
int main() {
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  int x = 0, y = 0;
  do {
    y_pos[x] = y;
    x = (x + dx) % n;
    y = (y + dy) % n;
  } while (x != 0);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &x, &y);
    int pos;
    if (y_pos[x] <= y)
      pos = y - y_pos[x];
    else
      pos = n - (y_pos[x] - y);
    ++cnt[pos];
  }
  int pos = max_element(cnt, cnt + n) - cnt;
  printf("%d %d\n", 0, pos);
  return 0;
}
