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