#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
int main() {
  int N, H, A, B, K;
  cin >> N >> H >> A >> B >> K;
  for (int i = 0; i < K; i++) {
    int x1, h1, x2, h2;
    cin >> x1 >> h1 >> x2 >> h2;
    if (x1 == x2)
      ans.push_back(abs(h1 - h2));
    else {
      int res = 0;
      if (h1 > B) {
        res += h1 - B;
        h1 = B;
      } else if (h1 < A) {
        res += A - h1;
        h1 = A;
      }
      res += abs(x2 - x1);
      res += abs(h2 - h1);
      ans.push_back(res);
    }
  }
  for (int i = 0; i < K; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
