#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long int n, h, a, b, k, s, d, d1, c, i;
  cin >> n >> h >> a >> b >> k;
  while (k--) {
    long long ta, fa, tb, fb;
    cin >> ta >> fa >> tb >> fb;
    if (fa > b && ta != tb) {
      d = fa - b;
      fa = b;
    } else if (fa < a && ta != tb) {
      d = a - fa;
      fa = a;
    } else
      d = 0;
    if (fb > b && ta != tb) {
      d1 = fb - b;
      fb = b;
    } else if (fb < a && ta != tb) {
      d1 = a - fb;
      fb = a;
    } else
      d1 = 0;
    c = max(fa, fb) - min(fa, fb);
    s = abs(ta - tb);
    cout << d + d1 + c + s << '\n';
  }
  return 0;
}
