#include <bits/stdc++.h>
using namespace std;
int ta, tb, fa, fb;
int main() {
  int n, h, a, b, k, ans = 0;
  scanf("%d%d%d%d%d", &n, &h, &a, &b, &k);
  while (k--) {
    ans = 0;
    scanf("%d%d%d%d", &ta, &fa, &tb, &fb);
    if (ta == tb) {
      ans = abs(fa - fb);
    } else {
      ans += abs(ta - tb);
      if (fa < a) {
        ans += (a - fa);
        fa = a;
      } else if (fa > b) {
        ans += (fa - b);
        fa = b;
      }
      if (fb < a) {
        ans += (a - fb);
        fb = a;
      } else if (fb > b) {
        ans += (fb - b);
        fb = b;
      }
      ans += abs(fa - fb);
    }
    cout << ans << endl;
  }
  return 0;
}
