#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int N, M, dx, dy;
int xidx[MAXN];
int cnt[MAXN];
int ans[MAXN][2];
int main() {
  cin >> N >> M >> dx >> dy;
  for (int i = 0; i < N; i++) xidx[((long long)i * dx) % N] = i;
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    int val = (y - (long long)xidx[x] * dy) % N;
    if (val < 0) val += N;
    cnt[val]++;
    ans[val][0] = x, ans[val][1] = y;
  }
  int best = 0;
  for (int i = 1; i < N; i++)
    if (cnt[best] < cnt[i]) best = i;
  cout << ans[best][0] << " " << ans[best][1] << "\n";
  return 0;
}
