#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, x, y, h, n, q;
int main() {
  cin >> n >> h >> a >> b >> q;
  while (q--) {
    cin >> x >> y >> c >> d;
    if (x == c) {
      cout << abs(d - y) << "\n";
    } else {
      int ans = abs(c - x);
      int temp = 0;
      if (y <= a) {
        temp = a;
        ans += a - y;
      } else if (y >= b) {
        temp = b;
        ans += y - b;
      } else
        temp = y;
      ans += abs(temp - d);
      cout << ans << "\n";
    }
  }
}
