#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) << endl;
      continue;
    }
    int t1 = min(abs(fa - a), abs(fa - b));
    int tmp = 0;
    if (t1 == abs(fa - a))
      tmp = fa - a;
    else
      tmp = fa - b;
    int tt = fa - tmp;
    if (fa >= a && fa <= b) {
      t1 = 0;
      tt = fa;
    }
    int t2 = abs(ta - tb);
    int t3 = abs(tt - fb);
    cout << t1 + t2 + t3 << endl;
  }
  int stop;
  cin >> stop;
  return 0;
}
