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