#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, a, b, k;
  int fa, fb, ta, tb;
  cin >> n >> h >> a >> b >> k;
  while (k--) {
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb) << '\n';
    } else {
      int mn, et;
      if (fa >= a && fa <= b) {
        mn = 0;
        et = fa;
      } else if (abs(a - fa) < abs(b - fa)) {
        mn = abs(a - fa);
        et = a;
      } else {
        mn = abs(b - fa);
        et = b;
      }
      int ans = 0;
      ans += mn;
      ans += abs(ta - tb);
      ans += abs(fb - et);
      cout << ans << '\n';
    }
  }
}
