#include <bits/stdc++.h>
using namespace std;
map<long long, long long> stuff;
int main() {
  long long n, m, dx, dy;
  cin >> n >> m >> dx >> dy;
  long long apples[100005][2];
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    long long z = a * dy - b * dx;
    z = ((z % n) + n) % n;
    stuff[z]++;
    apples[i][0] = a;
    apples[i][1] = b;
  }
  long long maxa = 0;
  long long index = -1;
  for (long long i = 0; i < n; ++i) {
    if (maxa < stuff[i]) {
      maxa = stuff[i];
      index = i;
    }
  }
  for (long long i = 0; i < m; ++i) {
    if ((apples[i][0] * dy - apples[i][1] * dx - index) % n == 0) {
      cout << apples[i][0] << ' ' << apples[i][1] << endl;
      return 0;
    }
  }
}
