#include <bits/stdc++.h>
using namespace std;
long long phi[1000005];
long long po(long long a, long long b, long long c) {
  if (b == 0) return 1;
  long long x = po(a, b / 2, c);
  x = (x * x) % c;
  if (b % 2) x = (a * x) % c;
  return x;
}
long long ans[1000005];
int main() {
  long long m;
  for (m = 0; m <= 1000001; m++) phi[m] = 1;
  for (m = 2; m <= 1000001; m++) {
    if (phi[m] != 1) continue;
    long long cur = m;
    while (1) {
      if (cur > 1000001) break;
      long long tmp = cur;
      long long mul = 1;
      while (tmp % m == 0) {
        tmp /= m;
        mul *= m;
      }
      mul = mul - mul / m;
      phi[cur] *= mul;
      cur += m;
    }
  }
  long long n, x, y;
  scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
  long long mul = phi[n];
  long long fir, sec;
  fir = po(x, mul - 1, n);
  long long tu;
  int i;
  long long u, v;
  for (i = 0; i < m; i++) {
    scanf("%lld%lld", &u, &v);
    tu = (u * fir) % n;
    v = v - (tu * y);
    v = v % n;
    v = (v + n) % n;
    ans[v]++;
  }
  int ma = -1;
  int res = -1;
  for (i = 0; i < n; i++)
    if (ans[i] > ma) {
      ma = ans[i];
      res = i;
    }
  printf("%d %d\n", 0, res);
}
