#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    long long x1, y1, x2, y2, ans = 0;
    cin >> x1 >> y1 >> x2 >> y2;
    ans += abs(x1 - x2);
    if (x1 != x2)
      if (y1 >= a && y1 <= b)
        ans += abs(y1 - y2);
      else {
        ans += min(abs(b - y1), abs(a - y1));
        if (abs(a - y1) == min(abs(b - y1), abs(a - y1)))
          y1 = a;
        else
          y1 = b;
        ans += abs(y1 - y2);
      }
    else
      ans += abs(y1 - y2);
    cout << ans << endl;
  }
  return 0;
}
