#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);
  for (int i = 0; i < k; i++) {
    int ta, fa, tb, fb;
    scanf("%d %d %d %d", &ta, &fa, &tb, &fb);
    if (ta == tb) {
      printf("%d\n", abs(fa - fb));
    } else if (fa >= a && fa <= b) {
      printf("%d\n", abs(ta - tb) + abs(fa - fb));
    } else if (fb >= a && fb <= b) {
      printf("%d\n", abs(ta - tb) + abs(fa - fb));
    } else {
      int aux = 0;
      if (fa > b && fb < a || fa < a && fb > b) aux = true;
      printf("%d\n", min(abs(fa - a), abs(fa - b)) +
                         min(abs(fb - a), abs(fb - b)) + abs(ta - tb) +
                         (aux ? abs(a - b) : 0));
    }
  }
  return 0;
}
