#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, a, b, k, i, t1, p1, t2, p2, x;
  cin >> n >> h >> a >> b >> k;
  for (i = 0; i < k; i++) {
    cin >> t1 >> p1 >> t2 >> p2;
    if (t1 == t2)
      cout << abs(p2 - p1) << endl;
    else {
      if (a <= p1 && p1 <= b)
        cout << abs(t2 - t1) + abs(p2 - p1) << endl;
      else {
        if (p1 < a)
          cout << abs(a - p1) + abs(p2 - a) + abs(t1 - t2) << endl;
        else {
          cout << abs(p1 - b) + abs(p2 - b) + abs(t1 - t2) << endl;
        }
      }
    }
  }
}
