#include <bits/stdc++.h>
using namespace std;
vector<int> all_x, all_y;
map<pair<int, int>, int> all_tree;
int pos_x[1000006], pos_y[1000006], value_x[1000006], value_y[1000006];
map<int, int> difference;
int minus_mod(int a, int b, int m) { return (a - b + m + m) % m; }
int main() {
  int n, m, dx, dy, i;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &dx);
  scanf("%d", &dy);
  for (i = 0; i < m; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    all_tree[{x, y}]++;
  }
  int now_x = 0, now_y = 0;
  for (i = 0; i < n; i++) {
    pos_x[now_x] = i;
    pos_y[now_y] = i;
    value_x[i] = now_x;
    value_y[i] = now_y;
    now_x += dx;
    now_x %= n;
    now_y += dy;
    now_y %= n;
  }
  map<pair<int, int>, int>::iterator it;
  it = all_tree.begin();
  while (it != all_tree.end()) {
    difference[minus_mod(pos_x[(it->first).first], pos_y[(it->first).second],
                         n)] += (it->second);
    it++;
  }
  int maximum_dif, maximum = -1;
  map<int, int>::iterator p;
  p = difference.begin();
  while (p != difference.end()) {
    if (maximum < p->second) {
      maximum_dif = p->first;
      maximum = p->second;
    }
    p++;
  }
  for (i = 0; i < n; i++) {
    if (all_tree[{value_x[i], value_y[minus_mod(i, maximum_dif, n)]}]) {
      printf("%d %d\n", value_x[i], value_y[minus_mod(i, maximum_dif, n)]);
      return 0;
    }
  }
  return 0;
}
