#include <bits/stdc++.h>
using namespace std;
long long n, m;
int q;
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  cin >> n >> m >> q;
  long long a = n / gcd(n, m);
  long long b = m / gcd(n, m);
  for (int i = 0; i < q; i++) {
    long long sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    long long secs, sece;
    if (sx == 1) {
      secs = (sy - 1) / a;
    } else {
      secs = (sy - 1) / b;
    }
    if (ex == 1) {
      sece = (ey - 1) / a;
    } else {
      sece = (ey - 1) / b;
    }
    printf(secs == sece ? "YES\n" : "NO\n");
  }
  return 0;
}
