#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long modInv(long long a, long long m) {
  long long x, y;
  long long g = gcdExtended(a, m, &x, &y);
  long long res = (x % m + m) % m;
  return res;
}
long long mpower(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long ncr(long long n, long long r) {
  if (r == 0)
    return 1;
  else if (r == 1)
    return n;
  else
    return ((((n * ncr(n - 1, r - 1)) % 1000000007) * modInv(r, 1000000007))) %
           1000000007;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  while (k--) {
    long long t1, f1, t2, f2;
    cin >> t1 >> f1 >> t2 >> f2;
    long long ans = 0;
    if (t1 == t2)
      ans = abs(f1 - f2);
    else {
      long long l1 = 0;
      long long l2 = 0;
      long long tmp1 = 0;
      long long tmp2 = 0;
      if (a <= f1 && f1 <= b) {
        tmp1 = f1;
        l1 = 0;
      } else {
        if (abs(f1 - a) >= abs(f1 - b))
          tmp1 = b;
        else
          tmp1 = a;
        l1 = min(abs(f1 - a), abs(f1 - b));
      }
      if (a <= f2 && f2 <= b) {
        tmp2 = f2;
        l2 = 0;
      } else {
        if (abs(f2 - a) >= abs(f2 - b))
          tmp2 = b;
        else
          tmp2 = a;
        l2 = min(abs(f2 - a), abs(f2 - b));
      }
      ans = abs(t1 - t2) + l1 + l2 + abs(tmp1 - tmp2);
    }
    cout << ans << endl;
  }
  return 0;
}
