#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); }
const long long inf = 0x7f7f7f7f;
const long long mod = 1e9 + 7;
double pi = acos(-1.0);
long long a[120];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, q;
  cin >> n >> m >> q;
  long long t = GCD(n, m);
  n /= t;
  m /= t;
  long long x1, y1, x2, y2;
  for (int i = 1; i <= q; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (t == 1) {
      cout << "YES" << endl;
      continue;
    }
    long long p1, p2;
    if (x1 == 1) {
      p1 = y1 / n;
      if (y1 % n) p1++;
    } else {
      p1 = y1 / m;
      if (y1 % m) p1++;
    }
    if (x2 == 1) {
      p2 = y2 / n;
      if (y2 % n) p2++;
    } else {
      p2 = y2 / m;
      if (y2 % m) p2++;
    }
    if (p1 == p2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
