#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p, l, h, q;
  cin >> n >> p >> l >> h >> q;
  while (q--) {
    int t1, f1, t2, f2;
    cin >> t1 >> f1 >> t2 >> f2;
    int d = (t1 - t2);
    if (d < 0) d = d * (-1);
    if (d == 0) {
      d = (f1 - f2);
      if (d < 0) d = d * (-1);
      cout << d << "\n";
      continue;
    }
    if (((f1 <= l) && (f2 <= l)) || ((f1 >= h) && (f2 >= h))) {
      int j = (2 * l - f1 - f2);
      int s = (2 * h - f1 - f2);
      if (j < 0) j = j * (-1);
      if (s < 0) s = s * (-1);
      if (j < s)
        d = d + j;
      else
        d = d + s;
    } else {
      int m = (f1 - f2);
      if (m < 0) m = m * (-1);
      d = d + m;
    }
    cout << d << "\n";
  }
}
