#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll g(ll a, ll b) {
  ll r = a % b;
  while (r) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
int main() {
  ll n, m, q;
  cin >> n >> m >> q;
  ll gc = g(n, m);
  ll lm = m / gc, ln = n / gc;
  for (int i = 0; i < q; i++) {
    ll sx, sy, ex, ey;
    ll im, in;
    cin >> sx >> sy >> ex >> ey;
    if (sx == 1) {
      in = (sy - 1) / ln;
    } else {
      in = (sy - 1) / lm;
    }
    if (ex == 1) {
      im = (ey - 1) / ln;
    } else {
      im = (ey - 1) / lm;
    }
    if (im == in) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
