#include <bits/stdc++.h>
using namespace std;
inline int abs(int a) {
  if (a < 0) {
    return -a;
  } else {
    return a;
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, h, a, b, k, ta, fa, tb, fb, ans;
  cin >> n >> h >> a >> b >> k;
  for (int i = 1; i <= k; i++) {
    cin >> ta >> fa >> tb >> fb;
    ans = 0;
    if (ta == tb) {
      ans = abs(fa - fb);
    } else if (fa > a && fa > b && fb > a && fb > b) {
      ans = abs(ta - tb) + abs(fa - fb) + min(fa - b, fb - b) * 2;
    } else if (fa < a && fa < b && fb < a && fb < b) {
      ans = abs(ta - tb) + abs(fa - fb) + min(a - fa, a - fb) * 2;
    } else {
      ans = abs(ta - tb) + abs(fa - fb);
    }
    cout << ans << endl;
  }
  return 0;
}
