#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int main() {
  std::ios::sync_with_stdio(false);
  long long n, h, a, b, k, ta, fa, tb, fb;
  cin >> n >> h >> a >> b >> k;
  while (k--) {
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb) << endl;
      continue;
    } else {
      if (fa >= a && fa <= b) {
        long long dis = abs(tb - ta);
        dis += abs(fb - fa);
        cout << dis << endl;
        continue;
      } else {
        if (abs(fa - a) < abs(fa - b)) {
          long long dis = abs(fa - a) + abs(tb - ta);
          dis += abs(fb - a);
          cout << dis << endl;
        } else {
          long long dis = abs(fa - b) + abs(tb - ta);
          dis += abs(fb - b);
          cout << dis << endl;
          continue;
        }
      }
    }
  }
  return 0;
}
