#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m, dx, dy;
int a[200000][2];
long long mul_inv(long long a, long long b) {
  long long b0 = b, t, q;
  long long x0 = 0, x1 = 1;
  if (b == 1) return 1;
  while (a > 1) {
    q = a / b;
    t = b, b = a % b, a = t;
    t = x0, x0 = x1 - q * x0, x1 = t;
  }
  if (x1 < 0) x1 += b0;
  return x1;
}
int cnt[2000000];
int main() {
  int i, j, k;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  for (i = 0; i < m; i++) scanf("%d%d", &a[i][0], &a[i][1]);
  for (i = 0; i < m; i++) {
    long long u = a[i][0] * mul_inv(dx, n) % n;
    long long t = a[i][1] - u * dy;
    t %= n, t += n, t %= n;
    cnt[t]++;
  }
  int ma = 0, mai;
  for (i = 0; i < n; i++) {
    if (ma < cnt[i]) ma = cnt[i], mai = i;
  }
  printf("%d %d", 0, mai);
  return 0;
}
