#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int h;
  int a;
  int b;
  int q;
  int y1, x1, y2, x2;
  cin >> n >> h >> a >> b >> q;
  int t = 0;
  while (t < q) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (y1 >= a && y1 <= b) {
      cout << abs(x2 - x1) + abs(y2 - y1);
      cout << endl;
    } else if (abs(y1 - a) <= abs(y1 - b)) {
      if (x1 != x2) {
        cout << abs(y1 - a) + abs(x2 - x1) + abs(y2 - a);
        cout << endl;
      } else {
        cout << abs(y2 - y1);
        cout << endl;
      }
    } else if (abs(y1 - a) >= abs(y1 - b)) {
      if (x1 != x2) {
        cout << abs(b - y1) + abs(x1 - x2) + abs(b - y2);
        cout << endl;
      } else {
        cout << abs(y2 - y1);
        cout << endl;
      }
    }
    t++;
  }
  return 0;
}
