#include <bits/stdc++.h>
using namespace std;
long long n, m, dx, dy;
pair<long long, long long> a[100005];
long long cnt[1000005];
pair<long long, long long> ans;
long long mx = 0ll;
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &dx, &dy);
  long long x = 1ll;
  long long y = 1ll;
  long long d = 0ll;
  for (int i = 1; i <= n; i++) {
    x += dx;
    y += dy;
    if (x > n) {
      x -= n;
    }
    if (y > n) {
      y -= n;
    }
    if (y == 2ll) {
      d = x - 1ll;
      break;
    }
  }
  d = -d;
  for (int i = 1; i <= m; i++) {
    scanf("%I64d%I64d", &a[i].first, &a[i].second);
    a[i].first++;
    a[i].second++;
    long long r = a[i].first + d * (a[i].second - 1ll);
    r = r % n;
    if (r < 0) {
      r += n;
    }
    cnt[r]++;
    if (cnt[r] > mx) {
      mx = cnt[r];
      ans = make_pair(a[i].first - 1ll, a[i].second - 1ll);
    }
  }
  printf("%I64d", ans.first);
  puts(" ");
  printf("%I64d", ans.second);
  return 0;
}
