#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, h, a, b, k;
  scanf("%lld%lld%lld%lld%lld", &n, &h, &a, &b, &k);
  while (k--) {
    long long int ta, fa, tb, fb;
    scanf("%lld%lld%lld%lld", &ta, &fa, &tb, &fb);
    long long int time = 0;
    if ((fa >= a && fa <= b) || (fb <= b && fb >= a)) {
      time = time + abs(ta - tb);
      time = time + abs(fa - fb);
      printf("%lld\n", time);
    } else {
      if (ta != tb) {
        time = abs(ta - tb);
        long long int flag = 0;
        long long int mem = min(abs(fa - a), abs(fa - b));
        long long int mem2 = min(abs(fb - a), abs(fb - b));
        if ((abs(fa - a) < abs(fa - b) && abs(fb - a) > abs(fb - b)) ||
            (abs(fa - a) > abs(fa - b) && abs(fb - a) < abs(fb - b))) {
          flag = 1;
        }
        time = time + mem;
        time = time + mem2;
        if (flag == 1) time = time + abs(a - b);
        printf("%lld\n", time);
      } else {
        long long int time = abs(fa - fb);
        printf("%lld\n", time);
      }
    }
  }
  return 0;
}
