#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, m, t, q, a, b, c, d, x, y, z;
int main() {
  scanf("%d %d %d %d %d\n", &n, &m, &x, &y, &q);
  for (int i = 0; i < q; i++) {
    int s = 0;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    s += abs(a - c);
    if (a != c) {
      if (!(b >= x && b <= y)) {
        if (abs(b - x) < abs(b - y)) {
          s += abs(b - x);
          b = x;
        } else {
          s += abs(b - y);
          b = y;
        }
      }
    }
    s += abs(b - d);
    printf("%d\n", s);
  }
}
