#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    long long a1, a2, b1, b2;
    cin >> a1 >> a2 >> b1 >> b2;
    long long near1 = abs(b1 - a1);
    long long near2 = abs(b2 - a2);
    long long time = near1;
    if (near1 == 0)
      time += near2;
    else {
      if (a2 < a && b2 < a)
        time += ((a - a2) + (a - b2));
      else if (a2 > b && b2 > b)
        time += ((a2 - b) + (b2 - b));
      else
        time += near2;
    }
    cout << time << "\n";
  }
}
