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