#include <bits/stdc++.h>
using namespace std;
inline long long getnum() {
  char c = getchar();
  long long num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
int A[1000007];
void EEA(int a, int b, int *x, int *y) {
  int x1 = 1, x2 = 0;
  int y1 = 0, y2 = 1;
  while (b) {
    int d = a / b;
    int temp1 = a % b;
    int temp2 = x1 - d * x2;
    int temp3 = y1 - d * y2;
    a = b;
    b = temp1;
    x1 = x2;
    x2 = temp2;
    y1 = y2;
    y2 = temp3;
  }
  *x = x1;
  *y = y1;
}
int main() {
  long long n = getnum(), m = getnum();
  int dx = getnum(), dy = getnum();
  int a, b;
  EEA(dx, n, &a, &b);
  for (; m--;) {
    int x = getnum();
    int y = getnum();
    long long ind = (long long)y - (long long)x * a * dy;
    ind = ind % n;
    if (ind < 0) ind += n;
    A[ind]++;
  }
  int mx = 0, ind;
  for (int i = 0; i < n; i++) {
    if (mx < A[i]) {
      mx = A[i];
      ind = i;
    }
  }
  printf("0 %d", ind);
}
