#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
long long add(long long a, long long b) {
  long long ret = a + b;
  if (ret >= 1000000007) ret -= 1000000007;
  return ret;
}
long long subtract(long long a, long long b) {
  long long ret = a - b;
  if (ret < 0) ret += 1000000007;
  return ret;
}
long long mult(long long a, long long b) {
  long long ret = a * b;
  if (ret >= 1000000007) ret %= 1000000007;
  return ret;
}
long long bigmod(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = mult(ret, a);
    b >>= 1;
    a = mult(a, a);
  }
  return ret;
}
long long inverse(long long n) { return bigmod(n, 1000000007 - 2); }
bool base[1000010];
vector<int> primes;
void sieve(int mx) {
  mx += 10;
  int x = sqrt(mx);
  for (int i = 3; i <= x; i += 2)
    if (base[i] == 0)
      for (int j = i * i, k = i << 1; j < mx; j += k) base[j] = 1;
  primes.push_back(2);
  for (int i = 3; i < mx; i += 2)
    if (base[i] == 0) primes.push_back(i);
}
bool checkBit(int n, int i) { return (n & (1 << i)); }
int setBit(int n, int i) { return (n | (1 << i)); }
int resetBit(int n, int i) { return (n & (~(1 << i))); }
int cnt[1000010];
int ans[1000010];
int main() {
  long long n, m, dx, dy;
  int x, y;
  scanf("%lld%lld", &n, &m);
  scanf("%lld%lld", &dx, &dy);
  for (int i = 0; i < n; ++i) cnt[(dy * i) % n] = i;
  pair<int, int> res;
  int mx = 0;
  while (m--) {
    scanf("%d%d", &x, &y);
    long long p = cnt[y];
    int row = (x - (dx * p) % n + n) % n;
    ++ans[row];
    if (ans[row] > mx) {
      mx = ans[row];
      res = {x, y};
    }
  }
  printf("%d %d\n", res.first, res.second);
  return 0;
}
