#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e7 + 3;
const long long MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  int x = 0, y = 0;
  vector<int> vx, vy;
  while (1) {
    vx.push_back(x);
    x = (x + dx) % n;
    if (!x) break;
  }
  while (1) {
    vy.push_back(y);
    y = (y + dy) % n;
    if (!y) break;
  }
  vector<int> Dx(n), Dy(n);
  for (int i = 0; i < n; i++) {
    Dx[vx[i]] = i, Dy[vy[i]] = i;
  }
  vector<int> cnt(n, 0);
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    cnt[(Dx[x] - Dy[y] + n) % n]++;
  }
  int mx = *max_element(cnt.begin(), cnt.end());
  for (int i = 0; i < n; i++) {
    if (cnt[i] == mx) {
      cout << vx[i] << " " << vy[0];
      return 0;
    }
  }
}
