#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  long long n, h, a, b, k;
  cin >> n >> k >> a >> b >> k;
  while (k--) {
    long long tower1, tower2, source, destination;
    cin >> tower1 >> source >> tower2 >> destination;
    long long ans = 0;
    if (tower1 == tower2) {
      cout << abs(source - destination) << endl;
    } else if (source > b) {
      ans += abs(source - b);
      ans += abs(tower2 - tower1);
      ans += abs(b - destination);
      cout << ans << endl;
    } else if (source < a) {
      ans += abs(a - source);
      ans += abs(tower2 - tower1);
      ans += abs(a - destination);
      cout << ans << endl;
    } else {
      ans += abs(tower2 - tower1);
      ans += abs(source - destination);
      cout << ans << endl;
    }
  }
}
