#include <bits/stdc++.h>
using namespace std;
int n, h, a, b, k, x, y, c, d;
int main() {
  scanf("%d%d%d%d%d", &n, &h, &a, &b, &k);
  while (k--) {
    scanf("%d%d%d%d", &x, &y, &c, &d);
    if (x == c)
      printf("%d\n", abs(d - y));
    else if (y > b)
      printf("%d\n", y - b + abs(x - c) + abs(d - b));
    else if (y < a)
      printf("%d\n", a - y + abs(x - c) + abs(d - a));
    else
      printf("%d\n", abs(x - c) + abs(d - y));
  }
}
