#include <bits/stdc++.h>
using namespace std;
const int MOD(1000000007);
const int INF((1 << 30) - 1);
const int MAXN(1000005);
int a[MAXN], b[MAXN], ans[2 * MAXN];
pair<int, int> p[2 * MAXN];
int main() {
  int n, m, dx, dy;
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  int nowx = 0, nowy = 0;
  for (int i = 0; i < n; i++) {
    a[nowx] = i;
    b[nowy] = i;
    nowx = (nowx + dx) % n;
    nowy = (nowy + dy) % n;
  }
  for (int i = 0; i < m; i++) {
    int x, y, d;
    scanf("%d%d", &x, &y);
    d = (a[x] - b[y]);
    if (d < 0) d += n;
    ans[d]++;
    p[d] = pair<int, int>(x, y);
  }
  int best = 0, first, second;
  for (int i = 0; i <= 2 * n; i++) {
    if (ans[i] > best) {
      best = ans[i];
      first = p[i].first;
      second = p[i].second;
    }
  }
  printf("%d %d", first, second);
}
