#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, h;
int xx[10005], yy[10005], aa[10005], bb[10005];
inline int read() {
  char c = getchar();
  int x = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - 48, c = getchar();
  return x;
}
int main() {
  n = read();
  h = read();
  a = read();
  b = read();
  k = read();
  for (register int i = 1; i <= k; i++) {
    xx[i] = read();
    yy[i] = read();
    aa[i] = read();
    bb[i] = read();
    long long ans = 0;
    ans = abs(xx[i] - aa[i]);
    if (xx[i] == aa[i]) {
      cout << abs(yy[i] - bb[i]) << endl;
      continue;
    }
    if (yy[i] > b)
      ans += yy[i] - b;
    else if (yy[i] < a)
      ans += a - yy[i];
    if (yy[i] >= a && yy[i] <= b)
      ans += abs(yy[i] - bb[i]);
    else if (yy[i] > b)
      ans += abs(b - bb[i]);
    else if (yy[i] < a)
      ans += abs(a - bb[i]);
    cout << ans << endl;
  }
  return 0;
}
