#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60) - 1;
long long const nax = 1e5 + 20;
int main() {
  int t = 1;
  while (t--) {
    int n, h, a, b, k;
    cin >> n >> h >> a >> b >> k;
    vector<int> ans;
    for (int i = 1; i <= k; i++) {
      int ta, fa, tb, fb;
      cin >> ta >> fa >> tb >> fb;
      if (ta == tb && fa == fb)
        cout << 0;
      else if (ta == tb && fa != fb)
        cout << abs(fa - fb);
      else if (fa >= a && fa <= b) {
        cout << abs(tb - ta) + abs(fb - fa);
      } else if (fa <= a || fa >= b) {
        int x = abs(fa - a);
        int y = abs(fa - b);
        int z = abs(fb - a);
        int p = abs(fb - b);
        cout << abs(tb - ta) + min(x + z, y + p);
      }
      cout << '\n';
    }
  }
  return 0;
}
