#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
const int infi = 1e9;
const long long Linfi = (long long)1e18;
const long long MOD = 1000000007;
const int c1 = 11;
const int c2 = 13;
int n, m, dx, dy;
int a[100005], b[100005];
map<int, int> M;
long long power(int a, int p, int M) {
  if (p == 0) return 1;
  if (p == 1) return a % M;
  long long ans = power(a, p / 2, M);
  ans = (ans * ans) % M;
  if (p % 2 == 1) ans = (ans * a) % M;
  return ans;
}
int phiEuler(int n) {
  int res = n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) res -= res / i;
    while (n % i == 0) n /= i;
  }
  if (n > 1) res -= res / n;
  return res;
}
void solve() {
  int phi = phiEuler(n);
  for (int i = 1; i <= m; i++) {
    long long inver = power(dx, phi - 1, n);
    long long k = inver * (n - a[i]);
    k %= n;
    long long tmp = (b[i] + k * dy) % n;
    M[tmp]++;
  }
  int maxx = 0, val = -1;
  for (typeof(M.begin()) i = M.begin(); i != M.end(); i++) {
    if (i->second > maxx) {
      maxx = i->second;
      val = i->first;
    }
  }
  cout << 0 << " " << val << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> dx >> dy;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
  }
  solve();
  return 0;
}
