#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
int n;
int h;
int a;
int b;
int k;
void input() { cin >> n >> h >> a >> b >> k; }
void solve() {
  while (k--) {
    int ta;
    int fa;
    int tb;
    int fb;
    cin >> ta >> fa >> tb >> fb;
    int ans = 0;
    if (ta != tb && (fa < a || fa > b)) {
      ans += min(abs(a - fa), abs(fa - b));
      if (abs(a - fa) < abs(fa - b))
        fa = a;
      else
        fa = b;
    }
    ans += abs(ta - tb);
    ans += abs(fb - fa);
    cout << ans << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
  int _times = 1;
  while (_times--) {
    input();
    solve();
  }
}
