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