#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, a, b, k;
  scanf("%d %d %d %d %d", &n, &h, &a, &b, &k);
  for (int i = 0; i < k; i++) {
    long long xx, yy, xxx, yyy, ans;
    ans = 0;
    cin >> xx >> yy >> xxx >> yyy;
    if (xx == xxx) {
      printf("%lld\n", abs(yyy - yy));
    } else {
      if (yyy >= b) {
        ans += abs(yy - b) + abs(yyy - b) + abs(xxx - xx);
        printf("%lld\n", ans);
      } else if (yyy <= a) {
        ans += abs(yy - a) + abs(yyy - a) + abs(xxx - xx);
        printf("%lld\n", ans);
      } else {
        ans += abs(yy - yyy) + abs(xxx - xx);
        printf("%lld\n", ans);
      }
    }
  }
  return 0;
}
