#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
double pi = acos((double)-1);
const int MOD = 1000000007;
const int INF = 2147483647;
int main() {
  clock_t tStart = clock();
  int tests = 1;
  for (int test = 1; test <= tests; test++) {
    int n, m, dx, dy;
    cin >> n >> m >> dx >> dy;
    vector<int> xi(m, 0), yi(m, 0);
    for (int i = 0; i < m; i++) {
      cin >> xi[i] >> yi[i];
    }
    vector<int> y(n, 0);
    int step_x = 0, step_y = 0;
    for (int i = 0; i < n; i++) {
      y[step_x] = step_y;
      step_x += dx;
      step_y += dy;
      step_x %= n;
      step_y %= n;
    }
    vector<int> groups_counter(n, 0);
    int groups_counter_max = 0;
    int groups_counter_index = 0;
    for (int i = 0; i < m; i++) {
      int k = (yi[i] - y[xi[i]] + n) % n;
      groups_counter[k]++;
      if (groups_counter[k] > groups_counter_max) {
        groups_counter_max = groups_counter[k];
        groups_counter_index = k;
      }
    }
    cout << 0 << " " << groups_counter_index << endl;
  }
}
