#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, tb, fa, fb;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb) << '\n';
    } else {
      int ans = 0;
      if (fa >= a && fa <= b) {
        ans += abs(ta - tb);
        ans += abs(fb - fa);
      }
      if (fa < a) {
        ans += abs(ta - tb);
        ans += a - fa;
        ans += abs(a - fb);
      }
      if (fa > b) {
        ans += abs(ta - tb);
        ans += fa - b;
        ans += abs(b - fb);
      }
      cout << ans << '\n';
    }
  }
}
