#include <bits/stdc++.h>
using namespace std;
struct Counter {
  static int k;
  Counter() { k++; }
  ~Counter() { k--; }
};
int Counter::k = 0;
template <typename T>
void pr(const string& name, T t) {
  cout << name << " = " << t << endl;
}
template <typename T, typename... Types>
void pr(const string& names, T t, Types... rest) {
  auto comma_pos = names.find(',');
  cout << names.substr(0, comma_pos) << " = " << t << ", ";
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest...);
}
void mod(long long& a, long long b) {
  a %= b;
  if (a < 0) a += b;
}
const long long MOD = 1000000007;
long long Am[1000005], DX, DY, Moves[1000005], N, M;
int main() {
  cin >> N >> M >> DX >> DY;
  long long p = 0;
  for (int i = (1); i <= (N); i++) {
    p = (p + DX) % N;
    Moves[p] = i;
  }
  for (int i = (1); i <= (M); i++) {
    long long x, y;
    cin >> x >> y;
    long long need = Moves[(N - x) % N];
    long long next_y = (y + DY * need) % N;
    Am[next_y]++;
  }
  int m = 0, best;
  for (int i = (0); i <= (N - 1); i++)
    if (Am[i] > m) {
      best = i;
      m = Am[i];
    }
  cout << "0 " << best << "\n";
}
