#include <bits/stdc++.h>
using namespace std;
int a, b, n, h, k;
int main() {
  scanf("%d%d%d%d%d", &n, &h, &a, &b, &k);
  while (k--) {
    int ta, tb, fa, fb;
    scanf("%d%d%d%d", &ta, &fa, &tb, &fb);
    int ans = abs(tb - ta);
    int temp = fa;
    if ((fa < a || fa > b) && ta != tb) {
      if (abs(a - fa) < abs(b - fa)) {
        temp = a;
      } else
        temp = b;
      ans += min(abs(a - fa), abs(b - fa));
    }
    ans += abs(fb - temp);
    printf("%d\n", ans);
  }
}
