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