#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, h, a, b, q;
  while (cin >> n >> h >> a >> b >> q) {
    long long i, ta, tb, fa, fb, low, high, low1, high1, ans, tdiff, fst, scnd;
    for (i = 1; i <= q; i++) {
      cin >> ta >> fa >> tb >> fb;
      if (ta == tb) {
        cout << abs(fa - fb) << endl;
      } else {
        long long low = abs(tb - ta);
        if (fa >= a && fa <= b)
          high = abs(fb - fa);
        else if (abs(b - fa) < abs(a - fa))
          high = abs(b - fa) + abs(b - fb);
        else
          high = abs(a - fa) + abs(a - fb);
        cout << low + high << endl;
      }
    }
  }
}
