#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
int num[MAXN];
int m, fi;
long long int n, dx, dy;
long long int pot(long long int a, int x) {
  long long int ret = 1;
  while (x) {
    if (x & 1) ret = (ret * a) % n;
    a = (a * a) % n;
    x /= 2;
  }
  return ret;
}
long long int dijeli(long long int a, long long int b) {
  return (a * pot(b, fi - 1)) % n;
}
long long int gcd(long long int a, long long int b) {
  if (!a) return b;
  return gcd(b % a, a);
}
int main() {
  scanf("%I64d%d%I64d%I64d", &n, &m, &dx, &dy);
  for (int i = 1; i < n; i++)
    if (gcd(i, n) == 1) fi++;
  for (int i = 0; i < m; i++) {
    long long int x, y;
    scanf("%I64d%I64d", &x, &y);
    long long int k = dijeli(y, dy);
    long long int poc = (k * dx) % n;
    long long int indeks = ((x - poc) % n + n) % n;
    num[indeks]++;
  }
  int rj = 0, maksi = -1;
  for (int i = 0; i < n; i++)
    if (num[i] > maksi) {
      maksi = num[i];
      rj = i;
    }
  printf("%d 0\n", rj);
  return 0;
}
