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