#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  while (k--) {
    long long ta, fa, tb, fb;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb)
      cout << (abs(fa - fb)) << endl;
    else {
      long long sum = 0;
      long long f = fa;
      if (fa >= b) {
        sum += abs(fa - b);
        f = b;
      } else if (fa <= a) {
        sum += abs(fa - a);
        f = a;
      }
      sum += abs(tb - ta);
      sum += abs(f - fb);
      cout << sum << endl;
    }
  }
  return 0;
}
