#include <bits/stdc++.h>
int const MAX = 1e5 + 5;
using namespace std;
int main() {
  long long n, h, a, b, k, p, q, r, s;
  cin >> n >> h >> a >> b >> k;
  for (long long i = 0; i < k; i++) {
    cin >> p >> q >> r >> s;
    if (p == r)
      cout << abs(q - s) << endl;
    else if (q >= a && q <= b)
      cout << abs(r - p) + abs(s - q) << endl;
    else {
      if (q > b)
        cout << q - b + abs(r - p) + abs(s - b) << endl;
      else
        cout << a - q + abs(r - p) + abs(s - a) << endl;
    }
  }
}
