#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    long long int aa, bb, cc, dd;
    cin >> aa >> bb >> cc >> dd;
    if (aa == cc) {
      cout << abs(bb - dd) << endl;
      continue;
    }
    long long int cnt = 0;
    if (bb < a) {
      cnt += abs(bb - a);
      cnt += abs(a - dd);
      cnt += abs(aa - cc);
    } else if (bb > b) {
      cnt += abs(bb - b);
      cnt += abs(b - dd);
      cnt += abs(aa - cc);
    } else {
      cnt += abs(aa - cc);
      cnt += abs(bb - dd);
    }
    cout << cnt << endl;
  }
  return 0;
}
