#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
long long inv(long long b) {
  if (b == 1) return 1;
  return (mod - mod / b) * inv(mod % b) % mod;
}
long long fpow(long long n, long long k) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % mod;
    n = n * n % mod;
  }
  return r;
}
int main() {
  long long n, h, a, b, k, i, j, x1, x2, y1, y2;
  scanf("%lld", &n);
  scanf("%lld", &h);
  scanf("%lld", &a);
  scanf("%lld", &b);
  scanf("%lld", &k);
  while (k--) {
    scanf("%lld", &x1);
    scanf("%lld", &y1);
    scanf("%lld", &x2);
    scanf("%lld", &y2);
    if (x1 == x2)
      printf("%lld\n", abs(y1 - y2));
    else if (y1 > a && y1 > b && y2 > a && y2 > b)
      printf("%lld\n", abs(x1 - x2) + abs(y1 - y2) + min(y1 - b, y2 - b) * 2);
    else if (y1 < a && y1 < b && y2 < a && y2 < b)
      printf("%lld\n", abs(x1 - x2) + abs(y1 - y2) + (max(y1, y2) - a) * (-2));
    else
      printf("%lld\n", abs(x1 - x2) + abs(y1 - y2));
  }
  return 0;
}
