#include <bits/stdc++.h>
using namespace std;
const long double pai = acos(-1.0L);
const long double eps = 1e-10;
const long long mod = 1e9 + 7;
const int MXN = 1e6 + 5;
long long GCD(long long x, long long y) {
  if (y == 0) return x;
  return GCD(y, x % y);
}
int main() {
  long long n, m, q;
  cin >> n >> m >> q;
  long long gcd = GCD(n, m);
  long long cn = n / gcd, cm = m / gcd;
  for (int i = 1; i <= q; i++) {
    long long a, b, x, y;
    scanf("%lld%lld%lld%lld", &a, &b, &x, &y);
    long long cb, cy;
    if (a == 1) {
      cb = b / cn + (b % cn != 0);
    }
    if (a == 2) {
      cb = b / cm + (b % cm != 0);
    }
    if (x == 1) {
      cy = y / cn + (y % cn != 0);
    }
    if (x == 2) {
      cy = y / cm + (y % cm != 0);
    }
    if (cb == cy)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
