#include <bits/stdc++.h>
using namespace std;
struct vec {
  long long x, y;
};
bool operator==(const vec& a, const vec& b) {
  return a.x == b.x and a.y == b.y;
}
bool operator!=(const vec& a, const vec& b) { return not(a == b); }
bool operator<(const vec& a, const vec& b) {
  return make_pair(a.x, a.y) < make_pair(b.x, b.y);
}
vec operator+(const vec& a, const vec& b) {
  return (vec){a.x + b.x, a.y + b.y};
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m;
  vec d;
  cin >> n >> m >> d.x >> d.y;
  vector<vec> apple(m);
  for (int i = 0; i < (m); ++i) cin >> apple[i].x >> apple[i].y;
  sort(apple.begin(), apple.end());
  vector<int> x2y(n);
  {
    vec p = d;
    while (p != (vec){0, 0}) {
      x2y[p.x] = p.y;
      p = p + d;
      p.x %= n;
      p.y %= n;
    }
  }
  vector<int> bucket(n);
  {
    int i = 0;
    for (int x = 0; x < (n); ++x) {
      for (; i < m and apple[i].x <= x; ++i) {
        bucket[(apple[i].y - x2y[x] + n) % n] += 1;
      }
    }
  }
  {
    int ix;
    int sz = -1;
    for (int i = 0; i < (n); ++i)
      if (sz < bucket[i]) {
        sz = bucket[i];
        ix = i;
      }
    cout << 0 << ' ' << ix << endl;
  }
  return 0;
}
