#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000;
int n, m, dx, dy;
pair<int, int> apples[MAXN + 3], appcpy[MAXN + 3];
int counter[2 * MAXN + 10];
void Read() {
  cin >> n >> m >> dx >> dy;
  for (int i = 0; i < m; i++) cin >> apples[i].first >> apples[i].second;
}
int GCDW(int a, int b, long long int &l, long long int &k) {
  if (!a) {
    l = 0;
    k = 1;
    return b;
  }
  int d = GCDW(b % a, a, k, l);
  l -= (b / a) * k;
  return d;
}
int revMod(int a, int mod) {
  long long int x, y;
  if (GCDW(a, mod, x, y) != 1) return -1;
  x %= mod;
  if (x < 0) x += mod;
  return (int)x;
}
pair<int, int> Solve() {
  int revx = revMod(dx, n);
  int revy = revMod(dy, n);
  if (revx == -1 || revy == -1) return make_pair(-1, -1);
  for (int i = 0; i < m; i++) {
    appcpy[i].first = ((long long int)apples[i].first * revx) % n;
    appcpy[i].second = ((long long int)apples[i].second * revy) % n;
  }
  for (int i = 0; i < m; i++)
    counter[(appcpy[i].first - appcpy[i].second + n) % n]++;
  int ret = 0;
  int ff = -1;
  for (int i = 0; i < n; i++) {
    if (counter[i] > ret) {
      ret = counter[i];
      ff = i;
    }
  }
  if (ff == -1) return apples[0];
  for (int i = 0; i < m; i++)
    if ((appcpy[i].first - appcpy[i].second + n) % n == ff) {
      return apples[i];
    }
  return apples[0];
}
int main() {
  ios_base::sync_with_stdio(0);
  Read();
  pair<int, int> res = Solve();
  cout << res.first << ' ' << res.second << '\n';
  return 0;
}
