#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;
    } else if (fa >= a && fa <= b) {
      cout << (abs(ta - tb) + abs(fa - fb)) << endl;
    } else if (fa > b) {
      cout << (abs(ta - tb) + abs(fb - b) + abs(fa - b)) << endl;
    } else if (fa < a) {
      cout << (abs(ta - tb) + abs(fb - a) + abs(fa - a)) << endl;
    }
  }
}
