#include <bits/stdc++.h>
using namespace std;
int n, h, a, b, k;
int ta, fa, tb, fb;
int cal(int x) { return abs(x - fa) + abs(x - fb); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> h >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb) << endl;
    } else {
      int re = abs(ta - tb);
      if (fa < a) {
        re += cal(a);
      } else {
        if (fa > b) {
          re += cal(b);
        } else {
          re += abs(fa - fb);
        }
      }
      cout << re << endl;
    }
  }
  return 0;
}
