#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 7;
int res[N];
pair<int, int> couple[N];
int n, m, dx, dy;
int inverse(int a, int n) {
  int r = n, newr = a;
  int t = 0, newt = 1;
  while (newr != 0) {
    int q = r / newr;
    int tmp = newr;
    newr = r - q * newr;
    r = tmp;
    tmp = newt;
    newt = t - q * newt;
    t = tmp;
  }
  if (t < 0) t += n;
  return t;
}
int main() {
  cin >> n >> m >> dx >> dy;
  int tmp = inverse(dx, n);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    int k = (((((long long)-u) * (long long)tmp) % n + n) % n);
    k = ((long long)v + (k * (long long)dy) % n) % n;
    res[k]++;
    couple[k] = make_pair(u, v);
  }
  int ans = 0;
  pair<int, int> tam = make_pair(0, 0);
  for (int i = 0; i < n; i++)
    if (res[i] > ans) {
      ans = res[i];
      tam = couple[i];
    }
  cout << tam.first << " " << tam.second;
  return 0;
}
