#include <bits/stdc++.h>
using namespace std;
int main() {
  int Q, n, h, a, b, ans, x1, x2, y1, y2;
  scanf("%d%d%d%d%d", &n, &h, &a, &b, &Q);
  for (int i = 1; i <= Q; i++) {
    ans = 0;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      printf("%d\n", abs(y1 - y2));
      continue;
    }
    if (y1 >= b && y2 >= b)
      ans = (y1 - b) + (y2 - b) + abs(x1 - x2);
    else if (y1 <= a && y2 <= a)
      ans = (a - y1) + (a - y2) + abs(x1 - x2);
    else
      ans = abs(y1 - y2) + abs(x1 - x2);
    printf("%d\n", ans);
  }
  return 0;
}
