#include <bits/stdc++.h>
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
using namespace std;
int main() {
  long long n, m, q;
  cin >> n >> m >> q;
  long long r = gcd(n, m);
  while (q--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long x = n / r;
    long long y = m / r;
    if (a == 1 && c == 1) {
      long long p = b / x + (b % x != 0);
      long long q = d / x + (d % x != 0);
      if (p == q) {
        cout << "YES" << '\n';
      } else {
        cout << "NO" << '\n';
      }
    } else if (a == 2 && c == 2) {
      long long p = b / y + (b % y != 0);
      long long q = d / y + (d % y != 0);
      if (p == q) {
        cout << "YES" << '\n';
      } else {
        cout << "NO" << '\n';
      }
    } else if (a == 1 && c == 2) {
      long long p = b / x + (b % x != 0);
      long long q = d / y + (d % y != 0);
      if (p == q) {
        cout << "YES" << '\n';
      } else {
        cout << "NO" << '\n';
      }
    } else if (a == 2 && c == 1) {
      long long p = b / y + (b % y != 0);
      long long q = d / x + (d % x != 0);
      if (p == q) {
        cout << "YES" << '\n';
      } else {
        cout << "NO" << '\n';
      }
    }
  }
}
