#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, h, a, b, k, i;
  cin >> n >> h >> a >> b >> k;
  for (i = 0; i < k; i++) {
    long int ta, tb, fa, fb;
    cin >> ta >> fa >> tb >> fb;
    long int count = 0;
    count = count + abs(ta - tb);
    long int min;
    int flag = 0;
    if (ta == tb) {
      count = count + abs(fa - fb);
    } else {
      if (a <= fa && fa <= b) {
        count = count + abs(fa - fb);
      } else {
        if (abs(fa - a) <= abs(fa - b)) {
          min = abs(fa - a);
          flag = -1;
        } else {
          min = abs(fa - b);
        }
        count = count + min;
        if (flag == 0) {
          count = count + abs(fb - b);
        } else {
          count = count + abs(fb - a);
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
