#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, h, A, B, k, S, T, ta, tb, fa, fb;
  cin >> n >> h >> A >> B >> k;
  for (long int i = 0; i < k; i++) {
    S = 0;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      S = abs(fa - fb);
    } else {
      if (fa < A) {
        S += abs(A - fa);
        T = A;
      } else if (fa > B) {
        S += abs(fa - B);
        T = B;
      } else {
        S += 0;
        T = fa;
      }
      S += abs(ta - tb);
      S += abs(fb - T);
    }
    cout << S << endl;
  }
  return 0;
}
