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