#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  while (k--) {
    long long ta, fa, tb, fb;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb) << endl;
      continue;
    }
    if (fa >= a && fa <= b) {
      cout << (abs(ta - tb) + abs(fa - fb)) << endl;
      continue;
    }
    long long ans = abs(ta - tb) +
                    min(abs(fa - a) + abs(fb - a), abs(fa - b) + abs(fb - b));
    cout << ans << endl;
  }
  return 0;
}
