#include <bits/stdc++.h>
using namespace std;
inline const int getint() {
  int r = 0, k = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') k = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) r = r * 10 + c - '0';
  return k * r;
}
const int N = 1e6 + 10;
void exgcd(long long a, long long b, long long &d, long long &x, long long &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, d, y, x);
  y -= a / b * x;
}
int n, m, c[N];
long long x, y, d, a, b, dx, dy;
int main() {
  cin >> n >> m >> dx >> dy;
  for (int i = (1); i <= (m); ++i) {
    cin >> x >> y;
    if (x == 0) {
      c[y]++;
      continue;
    }
    exgcd(dx, n, d, a, b);
    if (x % d != 0) continue;
    a = (a + n) % n;
    a = (a * x) % n;
    x = ((x - a * dx) % n + n) % n;
    y = ((y - a * dy) % n + n) % n;
    c[y]++;
  }
  int mx = 0, pos = -1;
  for (int i = 0; i < (n); ++i)
    if (c[i] > mx) pos = i, mx = c[i];
  if (pos == -1)
    cout << x << ' ' << y << endl;
  else
    cout << 0 << ' ' << pos << endl;
  return 0;
}
