#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    long long fx, tx, fy, ty;
    cin >> tx >> fx >> ty >> fy;
    if (tx == ty) {
      cout << abs(fx - fy) << "\n";
    } else if (a <= fx && fx <= b || a <= fy && fy <= b) {
      cout << abs(tx - ty) + abs(fx - fy) << "\n";
    } else {
      cout << abs(tx - ty) +
                  min(abs(fx - a) + abs(fy - a), abs(fx - b) + abs(fy - b))
           << "\n";
    }
  }
}
