#include <bits/stdc++.h>
using namespace std;
long long n, m, q;
long long sx, sy, ex, ey;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
signed main() {
  scanf("%lld%lld%lld", &n, &m, &q);
  long long pts = gcd(n, m);
  long long pin = n / pts;
  long long pout = m / pts;
  for (register long long i = 1; i <= q; i++) {
    scanf("%lld%lld%lld%lld", &sx, &sy, &ex, &ey);
    long long poss, pose;
    if (sx == 1) poss = (sy - 1) / pin;
    if (sx == 2) poss = (sy - 1) / pout;
    if (ex == 1) pose = (ey - 1) / pin;
    if (ex == 2) pose = (ey - 1) / pout;
    if (poss == pose) {
      puts("YES");
      continue;
    }
    puts("NO");
  }
  return 0;
}
