#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  while (k--) {
    long long ta, fa;
    long long tb, fb;
    cin >> ta >> fa >> tb >> fb;
    if (ta > tb) {
      swap(ta, tb);
      swap(fa, fb);
    }
    long long total = tb - ta;
    if (ta != tb) {
      if (fa < a) {
        total += a - fa;
        fa = a;
      }
      if (fa > b) {
        total += fa - b;
        fa = b;
      }
      if (fb < a) {
        total += a - fb;
        fb = a;
      }
      if (fb > b) {
        total += fb - b;
        fb = b;
      }
    }
    if (fa > fb) swap(fa, fb);
    total += fb - fa;
    cout << total << endl;
  }
  return 0;
}
