#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, h, a, b, k, ta, tb, fa, fb;
  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) << "\n";
    else {
      if (fa >= a && fa <= b) {
        cout << abs(ta - tb) + abs(fa - fb) << "\n";
      } else if (fa < a) {
        cout << a - fa + abs(ta - tb) + abs(a - fb) << "\n";
      } else {
        cout << fa - b + abs(ta - tb) + abs(b - fb) << "\n";
      }
    }
  }
}
