#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll n, m, q;
ll sx, sy, ex, ey;
void solve(ll& a, ll x, ll y) {
  if (x == 1) {
    a = (y - 1) / n + 1;
  } else {
    a = (y - 1) / m + 1;
  }
}
int main() {
  cin >> n >> m >> q;
  ll gc = gcd(n, m);
  n /= gc, m /= gc;
  while (q--) {
    cin >> sx >> sy >> ex >> ey;
    ll a, b;
    solve(a, sx, sy);
    solve(b, ex, ey);
    if (a == b)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
