#include <bits/stdc++.h>
#pragma GCC target("popcnt")
#pragma GCC optimize("tree-vectorize")
using namespace std;
const long double EPS = 1e-10;
const long long int MOD = 1000000007ll;
const long long int mod1 = 1000000009ll;
const long long int mod2 = 1100000009ll;
int INF = (int)1e9;
long long int INFINF = (long long int)1e18;
int debug = 0;
long long int bit_count(long long int _x) {
  long long int _ret = 0;
  while (_x) {
    if (_x % 2 == 1) _ret++;
    _x /= 2;
  }
  return _ret;
}
long long int power(long long int _a, long long int _b) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
long long int add(long long int a, long long int b, long long int m = MOD) {
  long long int x = (a % m + b % m) % m;
  return x;
}
long long int sub(long long int a, long long int b, long long int m = MOD) {
  long long int x = ((a % m) - (b % m) + m) % m;
  return x;
}
long long int mul(long long int a, long long int b, long long int m = MOD) {
  long long int x = ((a % m) * (b % m)) % m;
  x %= m;
  return x;
}
long long int powermod(long long int _a, long long int _b,
                       long long int _m = MOD) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a) % _m;
    _b /= 2;
    _a = (_a * _a) % _m;
  }
  return _r % _m;
}
long long int invmod(long long int a, long long int m = MOD) {
  return powermod(a, m - 2, m);
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
void printVector(vector<int> v) {
  for (int it : v) printf("%d ", it);
  printf("\n");
}
clock_t starttime;
void perr() {
  cerr << "Time taken: " << fixed << setprecision(6)
       << (double)(clock() - starttime) / (double)CLOCKS_PER_SEC
       << " seconds.\n";
}
const int N = (1e5) + 5;
const int M = (2e5) + 5;
const int LN = 20;
const int sz = 2000;
const int B = 32;
const int BB = (1e9 + sz - 1) / sz;
int dx[] = {0, 0, -1, 1, 1, -1, 1, -1};
int dy[] = {-1, 1, 0, 0, 1, -1, -1, 1};
int n, h, a, b, k, x;
string ss;
int main() {
  cin >> n >> h >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    int ta, fa, tb, fb;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb) << endl;
      continue;
    }
    int tmp;
    if (fa < a || fa > b) {
      tmp = (abs(fa - a) < abs(fa - b)) ? a : b;
    } else
      tmp = fa;
    int mn = (fa < a || fa > b) ? min(abs(fa - a), abs(fa - b)) : 0;
    int dis = mn + abs(tb - ta);
    dis += abs(fb - tmp);
    cout << dis << endl;
  }
  return 0;
}
