#include <bits/stdc++.h>
using namespace std;
int n, m, dx, dy;
int sz[1000000];
int pos[1000000];
int cur = 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> dx >> dy;
  pos[dx] = cur;
  int now = dx;
  while (true) {
    now = (now + dx) % n;
    cur++;
    pos[now] = cur;
    if (pos[(now + dx) % n] != 0) break;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    int dis = n - x;
    if (dis == 0) {
      sz[y]++;
      continue;
    }
    if (pos[dis] < pos[0]) {
      int cnt = pos[0] - pos[x];
      long long nw = ((long long)y + (long long)dy * (long long)cnt) % n;
      sz[(int)nw]++;
    } else {
      int cnt = (n - pos[x]) + pos[0];
      long long nw = ((long long)y + (long long)dy * (long long)cnt) % n;
      sz[(int)nw]++;
    }
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (sz[i] > sz[mx]) {
      mx = i;
    }
  }
  cout << 0 << " " << mx << endl;
  return 0;
}
