#include <bits/stdc++.h>
using namespace std;
long long int n, m;
int q;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
int main() {
  scanf("%I64d %I64d %d", &n, &m, &q);
  long long int GCD = gcd(n, m);
  long long int ga = n / GCD, gb = m / GCD;
  while (q--) {
    long long int sa, sb, ea, eb;
    scanf("%I64d %I64d %I64d %I64d", &sa, &sb, &ea, &eb);
    long long int posa, posb;
    if (sa == 1)
      posa = (sb - 1) / ga;
    else
      posa = (sb - 1) / gb;
    if (ea == 1)
      posb = (eb - 1) / ga;
    else
      posb = (eb - 1) / gb;
    if (posa == posb)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
