#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void solve() {
  long long n, m, q;
  cin >> n >> m >> q;
  long long g = gcd(n, m);
  while (q--) {
    long long sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    long long a, b;
    if (sx == 1)
      a = n / g;
    else
      a = m / g;
    if (ex == 1)
      b = n / g;
    else
      b = m / g;
    if ((sy - 1) / a == (ey - 1) / b)
      cout << "YES";
    else
      cout << "NO";
    cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
