#include <bits/stdc++.h>
using namespace std;
int n, m, dx, dy, p[1000005], vis[1000006], ans, in;
void solve() {
  cin >> n >> m >> dx >> dy;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    p[cur] = i;
    cur = (cur + dx) % n;
  }
  for (int i = 0; i < m; i++) {
    int first, second;
    cin >> first >> second;
    int g = (second - 1LL * p[first] * dy) % n;
    g = (g + n) % n;
    vis[g]++;
  }
  for (int i = 0; i < n; i++) {
    if (ans < vis[i]) {
      ans = vis[i];
      in = i;
    }
  }
  cout << 0 << " " << in << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
