#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  for (int j = 1; j <= k; j++) {
    int ta, fa, tb, fb;
    cin >> ta >> fa >> tb >> fb;
    if (ta == tb) {
      cout << abs(fa - fb) << endl;
      continue;
    }
    if (fa > b)
      cout << fa - b + abs(ta - tb) + abs(b - fb) << endl;
    else if (fa < a)
      cout << a - fa + abs(ta - tb) + abs(a - fb) << endl;
    else
      cout << abs(ta - tb) + abs(fa - fb) << endl;
  }
}
