#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  long long x = 0, w = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return w ? -x : x;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long n, m, q, z[3];
int main() {
  n = in();
  m = in();
  q = in();
  z[0] = gcd(n, m);
  z[1] = n / z[0];
  z[2] = m / z[0];
  long long x1, y1, x2, y2;
  while (q--) {
    x1 = in();
    y1 = in();
    x2 = in();
    y2 = in();
    if (z[0] == 1) {
      printf("YES\n");
      continue;
    }
    long long k1, k2;
    k1 = y1 / z[x1] + 1;
    if (y1 % z[x1] == 0) --k1;
    k2 = y2 / z[x2] + 1;
    if (y2 % z[x2] == 0) --k2;
    if (k1 == k2) {
      printf("YES\n");
      continue;
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
