#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)(1e9 + 7);
long long modpow(long long a, long long b) {
  if (!b) return 1;
  a %= mod;
  return modpow(a * a % mod, b / 2) * (b & 1 ? a : 1) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, h, a, b;
  cin >> n >> h >> a >> b;
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int x0, y0;
    cin >> x0 >> y0;
    int x1, y1;
    cin >> x1 >> y1;
    if (x0 == x1)
      cout << abs(y0 - y1) << endl;
    else {
      if ((a <= y0 && y0 <= b))
        cout << abs(y0 - y1) + abs(x0 - x1) << endl;
      else {
        int d1 = abs(x0 - x1) + abs(y0 - a) + abs(a - y1);
        int d2 = abs(x0 - x1) + abs(y0 - b) + abs(b - y1);
        cout << min(d1, d2) << endl;
      }
    }
  }
  return 0;
}
