#include <bits/stdc++.h>
int nearest(int fa, int a, int b) {
  if (fa < a) {
    return a;
  } else if (fa > b) {
    return b;
  } else {
    return fa;
  }
}
int foo(int ta, int fa, int tb, int fb, int a, int b) {
  if (ta == tb) {
    return std::abs(fa - fb);
  }
  int near = nearest(fa, a, b);
  return std::abs(fa - near) + std::abs(fb - near) + std::abs(ta - tb);
}
int main() {
  int n, h, a, b, k;
  std::cin >> n >> h >> a >> b >> k;
  for (int kk = 0; kk < k; kk++) {
    int ta, fa, tb, fb;
    std::cin >> ta >> fa >> tb >> fb;
    std::cout << foo(ta, fa, tb, fb, a, b) << std::endl;
  }
  return 0;
}
