#include <bits/stdc++.h>
using namespace std;
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a < b) return gcd(a, b % a);
  return gcd(b, a % b);
}
int main() {
  unsigned long long n, m, q;
  cin >> n >> m >> q;
  unsigned long long g = gcd(n, m);
  unsigned long long nn = n / g, mm = m / g;
  while (q--) {
    unsigned long long sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    unsigned long long bs, be;
    if (sx == 1) {
      bs = (sy - 1) / nn;
    } else {
      bs = (sy - 1) / mm;
    }
    if (ex == 1) {
      be = (ey - 1) / nn;
    } else {
      be = (ey - 1) / mm;
    }
    if (bs == be)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
