#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e;
  while (e--) {
    long long int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A == C) {
      cout << max(B, D) - min(B, D) << endl;
    } else {
      if (B <= c && D <= c) {
        cout << max(A, C) - min(A, C) + c - B + c - D << endl;
      } else if (B >= d && D >= d) {
        cout << max(A, C) - min(A, C) + B - d + D - d << endl;
      } else {
        cout << max(A, C) - min(A, C) + max(B, D) - min(B, D) << endl;
      }
    }
  }
}
