#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
using ll = long long;
const int INF = 2e9 + 10;
using pii = pair<int, int>;
using vi = vector<int>;
int n, h, a, b, k;
int main() {
  cin >> n >> h >> a >> b >> k;
  while (k--) {
    int ta, fa, tb, fb;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb) << endl;
    } else if (a > max(fa, fb)) {
      cout << abs(ta - tb) + 2 * a - fa - fb << endl;
    } else if (b < min(fa, fb)) {
      cout << abs(ta - tb) + fa + fb - 2 * b << endl;
    } else {
      cout << abs(ta - tb) + abs(fa - fb) << endl;
    }
  }
  return 0;
}
