#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
long long n, m, dx, dy;
int x[N];
int ans[N];
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &dx, &dy);
  for (int i = 0; i < n; ++i) {
    x[(dy * i) % n] = (dx * i) % n;
  }
  for (int i = 0; i < m; ++i) {
    int tx, ty;
    scanf("%d%d", &tx, &ty);
    tx = (tx - x[ty] + n) % n;
    ++ans[tx];
  }
  int bst = 0;
  int bstX = 0;
  for (int i = 0; i < n; ++i) {
    if (ans[i] > bst) {
      bst = ans[i];
      bstX = i;
    }
  }
  printf("%d %d\n", bstX, 0);
  return 0;
}
