#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;
int main() {
  int n, h, a, b, k;
  cin >> n >> h >> a >> b >> k;
  for (int query = int(1); query <= int(k); query++) {
    int t_a, f_a, t_b, f_b;
    cin >> t_a >> f_a >> t_b >> f_b;
    if (t_a == t_b || (a <= f_a && f_a <= b && a <= f_b && f_b <= b)) {
      cout << abs(t_a - t_b) + abs(f_a - f_b) << endl;
    } else {
      cout << min(abs(f_a - a) + abs(t_a - t_b) + abs(f_b - a),
                  abs(f_a - b) + abs(t_a - t_b) + abs(f_b - b))
           << endl;
    }
  }
  return 0;
}
