#include <bits/stdc++.h>
using namespace std;
long long i, j, k, c = 0, m;
long long n;
void solve() {
  long long h, a, b;
  cin >> n >> h >> a >> b >> k;
  long long fa, ta, fb, tb;
  for (i = 0; i < k; i++) {
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb);
      cout << endl;
      continue;
    }
    if (fa >= a && fa <= b) {
      if (fb >= a && fb <= b)
        cout << abs(ta - tb) + abs(fa - fb);
      else
        cout << min(abs(fa - a) + abs(fb - a), abs(fa - b) + abs(fb - b)) +
                    abs(ta - tb);
    } else {
      if (fb >= a && fb <= b)
        cout << abs(ta - tb) +
                    min(abs(fa - a) + abs(fb - a), abs(fa - b) + abs(fb - b));
      else
        cout << min(abs(fa - a) + abs(fb - a), abs(fa - b) + abs(fb - b)) +
                    abs(ta - tb);
    }
    cout << endl;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int T = 1;
  while (T--) {
    solve();
    cout << endl;
  }
  return 0;
}
