#include <bits/stdc++.h>
using namespace std;
long long xabs(long long a) { return a >= 0 ? a : -a; }
int main(int argc, char** argv) {
  long long n, h, a, b;
  int k;
  cin >> n >> h >> a >> b >> k;
  for (int z = 0; z < k; ++z) {
    long long ta, fa, tb, fb;
    long long res = -1;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      res = xabs(fb - fa);
    } else {
      res = xabs(ta - tb);
      if (fa >= b && fb >= b) {
        res += fa - b;
        res += fb - b;
      } else if (fa <= a && fb <= a) {
        res += a - fa;
        res += a - fb;
      } else {
        res += xabs(fb - fa);
      }
    }
    cout << res << endl;
  }
  return 0;
}
