#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, h, a, b, q, sum;
int main() {
  cin >> n >> h >> a >> b >> q;
  for (int i = 0; i < q; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2) {
      sum += abs(y2 - y1);
    } else {
      if (y1 <= a) {
        sum += a - y1;
        y1 = a;
      } else if (y1 >= b) {
        sum += y1 - b;
        y1 = b;
      }
      sum += abs(x2 - x1);
      if (y2 <= y1) {
        sum += y1 - y2;
      } else if (y2 >= y1) {
        sum += y2 - y1;
      }
    }
    cout << sum << endl;
    sum = 0;
  }
}
