#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
int main() {
  int n, h, a, b, k;
  scanf("%d%d%d%d%d", &n, &h, &a, &b, &k);
  for (int i = 0; i < k; i++) {
    int ta, fa, tb, fb;
    scanf("%d%d%d%d", &ta, &fa, &tb, &fb);
    int ans = 0;
    if (ta == tb)
      ans = ((fa - fb) >= 0 ? (fa - fb) : (-(fa - fb)));
    else {
      if (fa < a && fa < a)
        ans = ((fa - a) >= 0 ? (fa - a) : (-(fa - a))) +
              ((fb - a) >= 0 ? (fb - a) : (-(fb - a))) +
              ((ta - tb) >= 0 ? (ta - tb) : (-(ta - tb)));
      else if (fa > b && fb > b)
        ans = ((fa - b) >= 0 ? (fa - b) : (-(fa - b))) +
              ((fb - b) >= 0 ? (fb - b) : (-(fb - b))) +
              ((ta - tb) >= 0 ? (ta - tb) : (-(ta - tb)));
      else
        ans = ((fa - fb) >= 0 ? (fa - fb) : (-(fa - fb))) +
              ((ta - tb) >= 0 ? (ta - tb) : (-(ta - tb)));
    }
    printf("%d\n", ans);
  }
  return 0;
}
