#include <bits/stdc++.h>
using namespace std;
long long k, t;
struct node {
  long long sum, x, y;
  bool flag;
} times[1000005];
long long query[100005][2];
long long n, m, dx, dy;
long long exGCD(long long a, long long b) {
  if (b == 0) {
    k = 1;
    t = 0;
    return a;
  }
  long long r = exGCD(b, a % b);
  long long tmp = k;
  k = t;
  t = tmp - (a / b) * t;
  return r;
}
int main(void) {
  long long Max = 0, Index = 0;
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &dx, &dy);
  exGCD(dx, n);
  k = (k % n + n) % n;
  k %= n;
  for (long long i = 0; i < m; ++i) {
    long long x, y;
    scanf("%I64d%I64d", &x, &y);
    query[i][0] = x, query[i][1] = y;
    long long temp = y - x * k * dy;
    temp = (temp % n + n) % n;
    temp %= n;
    times[temp].sum++;
    if (times[temp].sum > Max) {
      Max = times[temp].sum;
      Index = temp;
    }
    if (times[temp].flag == 0) {
      times[temp].x = x;
      times[temp].y = y;
      times[temp].flag = 1;
    }
  }
  printf("%I64d %I64d\n", times[Index].x, times[Index].y);
  return 0;
}
