#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  long long n, h;
  cin >> n >> h >> a >> b;
  long long k;
  cin >> k;
  long long towl1, floor1;
  long long towl2, floor2;
  long long ans;
  for (int i = 1; i <= k; i++) {
    ans = 0;
    cin >> towl1 >> floor1;
    cin >> towl2 >> floor2;
    if (towl1 != towl2) {
      if (floor1 < floor2) {
        if (a > floor2)
          ans += (a - floor2) + (a - floor1) + abs(towl1 - towl2);
        else if (b < floor1)
          ans += (floor1 - b) + (floor2 - b) + abs(towl1 - towl2);
        else
          ans += (floor2 - floor1) + abs(towl1 - towl2);
      } else {
        if (a > floor1)
          ans += (a - floor1) + (a - floor2) + abs(towl1 - towl2);
        else if (b < floor2)
          ans += (floor1 - b) + (floor2 - b) + abs(towl1 - towl2);
        else
          ans += (floor1 - floor2) + abs(towl1 - towl2);
      }
    } else
      ans = abs(floor1 - floor2);
    cout << ans << endl;
  }
}
