#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC optimize("fast-math,unroll-loops")
using namespace std;
const int DEBUG = 0;
mt19937 gen(
    (unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
#pragma comment(linker, "/STACK:76777216")
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(cout.fixed);
  cout.precision(12);
  auto START_TIME = chrono::high_resolution_clock::now();
  long long n, m, q;
  cin >> n >> m >> q;
  long long g = gcd(n, m);
  n /= g;
  m /= g;
  while (q--) {
    long long sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    --sy;
    --ey;
    long long ps, pe;
    if (sx == 1) {
      ps = sy / n;
    } else {
      ps = sy / m;
    }
    if (ex == 1) {
      pe = ey / n;
    } else {
      pe = ey / m;
    }
    if (ps == pe) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
