#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  long long n, m, q;
  scanf("%lld%lld%lld", &n, &m, &q);
  long long k = gcd(n, m);
  for (int i = 1; i <= q; i++) {
    long long a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    if (a == 1 && c == 1) {
      long long t = n / k;
      if ((b - 1) / t == (d - 1) / t)
        printf("YES\n");
      else
        printf("NO\n");
    } else if (a == 2 && c == 2) {
      long long t = m / k;
      if ((b - 1) / t == (d - 1) / t)
        printf("YES\n");
      else
        printf("NO\n");
    } else if (a == 1 && c == 2) {
      long long x = n / k, y = m / k;
      if ((b - 1) / x == (d - 1) / y)
        printf("YES\n");
      else
        printf("NO\n");
    } else if (a == 2 && c == 1) {
      long long x = n / k, y = m / k;
      if ((b - 1) / y == (d - 1) / x)
        printf("YES\n");
      else
        printf("NO\n");
    }
  }
  return 0;
}
