#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    int ta, tb, fa, fb;
    cin >> ta >> fa >> tb >> fb;
    int ans;
    int elevatorDistance, towerDistance, floorDistance, currentFloor;
    bool skip = false;
    if (ta == tb) {
      cout << abs(fa - fb) << '\n';
      skip = true;
    }
    if (!skip) {
      if (fa <= b and fa >= a) {
        elevatorDistance = 0;
        currentFloor = fa;
      } else {
        elevatorDistance = min(abs(fa - a), abs(fa - b));
        if (abs(fa - a) < abs(fa - b))
          currentFloor = a;
        else
          currentFloor = b;
      }
      towerDistance = abs(ta - tb);
      floorDistance = abs(currentFloor - fb);
      ans = elevatorDistance + towerDistance + floorDistance;
      cout << ans << '\n';
    }
  }
}
