#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  int ta, fa, tb, fb;
  int t1, t2, t3, t4;
  while (k--) {
    scanf("%d%d%d%d", &ta, &fa, &tb, &fb);
    if (ta == tb) {
      printf("%d\n", abs(fa - fb));
    } else {
      if (fa >= a && fa <= b)
        t1 = 0;
      else
        t1 = min(abs(fa - a), abs(fa - b));
      if (fb >= a && fb <= b)
        t2 = 0;
      else
        t2 = min(abs(fb - a), abs(fb - b));
      t3 = abs(ta - tb);
      int e1, e2;
      int add = 0;
      if (fa > b) {
        e1 = b;
      } else if (fa < a) {
        e1 = a;
      } else
        e1 = fa;
      if (fb > b) {
        e2 = b;
      } else if (fb < a) {
        e2 = a;
      } else
        e2 = fb;
      add = abs(e1 - e2);
      printf("%d\n", t1 + t2 + t3 + add);
    }
  }
}
