#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  int ta, fa, tb, fb;
  int thisAns;
  for (int i = 0; i < k; i++) {
    cin >> ta >> fa >> tb >> fb;
    thisAns = abs(ta - tb);
    if (fa < a && fb < a && ta != tb) {
      thisAns += (abs(fa - a) + abs(fb - a));
    } else if (fa > b && fb > b && ta != tb) {
      thisAns += (abs(fa - b) + abs(fb - b));
    } else {
      thisAns += abs(fa - fb);
    }
    cout << thisAns << endl;
  }
  return 0;
}
