#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, h, a, b, q;
  cin >> n >> h >> a >> b >> q;
  while (q--) {
    long long int fa, fb, ta, tb;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb && fa == fb) {
      cout << 0 << endl;
      continue;
    }
    long long int jmp = abs(ta - tb);
    if (jmp == 0) {
      cout << abs(fa - fb) << endl;
      continue;
    }
    if (fa >= a && fa <= b) {
      jmp += abs(fa - fb);
    } else if (fa < a) {
      jmp += abs(a - fa);
      fa = a;
      jmp += abs(fa - fb);
    } else if (fa > b) {
      jmp += abs(b - fa);
      fa = b;
      jmp += abs(fa - fb);
    }
    cerr << "ans";
    cout << jmp << endl;
  }
}
