#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &x) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-' && c != -1)
    ;
  if (c == -1) return;
  if (c == '-') sg = 1, c = getchar();
  for (x = 0; c >= '0' && c <= '9';
       x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  if (sg) x = -x;
}
template <class T>
void print(T x) {
  if (x < 0) return putchar('-'), print(-x);
  if (x < 10) {
    putchar(x + '0');
    return;
  }
  print(x / 10);
  putchar(x % 10 + '0');
}
template <class U, class V>
inline void gn(U &u, V &v) {
  gn(u);
  gn(v);
}
template <class U, class V, class W>
inline void gn(U &u, V &v, W &w) {
  gn(u);
  gn(v, w);
}
template <class T>
void println(T &x) {
  print(x);
  putchar('\n');
}
template <class T>
void printsp(T &x) {
  print(x);
  putchar(' ');
}
template <class U, class V>
inline void print(U &u, V &v) {
  printsp(u);
  println(v);
}
template <class U, class V, class W>
inline void print(U &u, V &v, W &w) {
  printsp(u);
  print(v, w);
}
int power(int a, int b, int m = 1000000007, int ans = 1) {
  for (; b; a = (long long)a * a % 1000000007, b >>= 1)
    if (b & 1) ans = (long long)ans * a % 1000000007;
  return ans;
}
int cnt[2000010];
int ex_gcd(int a, int b, int &x, int &y) {
  if (b == 0) return x = 1, y = 0, a;
  int g = ex_gcd(b, a % b, y, x);
  y -= a / b * x;
  return g;
}
int xx[2000010], yy[2000010];
int main() {
  int x, y, p;
  int n, m, dx, dy;
  scanf("%d %d %d %d", &n, &m, &dx, &dy);
  int g = ex_gcd(dx, n, x, y);
  for (int i = 1; i <= m; i++) scanf("%d %d", &xx[i], &yy[i]);
  for (int i = 1; i <= m; i++) {
    int s =
        (n + ((long long)yy[i] - (long long)dy * (((long long)x * xx[i]) % n)) %
                 n) %
        n;
    cnt[s]++;
  }
  int res = 0;
  for (int i = 0; i < n; i++) res = max(res, cnt[i]);
  for (int i = 0; i < n; i++) {
    if (cnt[i] == res) {
      p = i;
      break;
    }
  }
  for (int i = 1; i <= m; i++) {
    int s =
        (n + ((long long)yy[i] - (long long)dy * (((long long)x * xx[i]) % n)) %
                 n) %
        n;
    if (s == p) {
      printf("%d %d", xx[i], yy[i]);
      return 0;
    }
  }
  return 0;
}
