#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
long long findR(long long per, long long r) {
  return ceil(r / (long double)per);
}
int main() {
  long long n, m, q;
  cin >> n >> m >> q;
  long long g = gcd(n, m);
  long long pn = n / g;
  long long pm = m / g;
  while (q--) {
    long long sx, sy;
    long long ex, ey;
    cin >> sx >> sy;
    cin >> ex >> ey;
    long long s1, s2;
    if (sx == 1) {
      s1 = findR(pn, sy);
    } else {
      s1 = findR(pm, sy);
    }
    if (ex == 1) {
      s2 = findR(pn, ey);
    } else {
      s2 = findR(pm, ey);
    }
    if (s1 == s2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
