#include <bits/stdc++.h>
using namespace ::std;
int main() {
  long long i, j, k, l, n, m, h, a, b, first, second, e, f, s = 0;
  cin >> n >> h >> a >> b >> k;
  for (i = (0); i <= (k - 1); i++) {
    cin >> e >> first >> f >> second;
    if (e > f) {
      if (first > b) {
        s += first - b;
        first = b;
      }
      if (first < a) {
        s += a - first;
        first = a;
      }
      s += e - f;
      s += abs(first - second);
    } else if (e == f) {
      s = abs(first - second);
    } else {
      if (first > b) {
        s += first - b;
        first = b;
      }
      if (first < a) {
        s += a - first;
        first = a;
      }
      s += abs(e - f);
      s += abs(first - second);
    }
    cout << s << '\n';
    s = 0;
  }
}
