#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int32_t main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  long long n, m, q;
  cin >> n >> m >> q;
  long long g = gcd(n, m);
  long long x = n / g, y = m / g;
  while (q--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long n1, n2;
    if (a == 1)
      n1 = (b - 1) / x;
    else
      n1 = (b - 1) / y;
    if (c == 1)
      n2 = (d - 1) / x;
    else
      n2 = (d - 1) / y;
    if (n1 == n2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
