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