#include <bits/stdc++.h>
using namespace std;
long long n, m, g, a1, a2, b1, b2, ans1, ans2;
int q;
long long gcd(long long x, long long y) {
  if (x == 0) {
    return y;
  }
  return gcd(y % x, x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> q;
  g = gcd(min(n, m), max(n, m));
  n = n / g;
  m = m / g;
  for (int i = 1; i <= q; i++) {
    cin >> a1 >> b1 >> a2 >> b2;
    if (a1 == 1) {
      ans1 = (b1 - 1) / n + 1;
    } else {
      ans1 = (b1 - 1) / m + 1;
    }
    if (a2 == 1) {
      ans2 = (b2 - 1) / n + 1;
    } else {
      ans2 = (b2 - 1) / m + 1;
    }
    if (ans1 == ans2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
