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