#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  long long n = 0, m = 0;
  long long q = 0;
  cin >> n >> m >> q;
  long long g = gcd(n, m);
  vector<vector<long long> > s(q, vector<long long>(4));
  for (long long i = 0; i < q; i++)
    cin >> s[i][0] >> s[i][1] >> s[i][2] >> s[i][3];
  for (long long i = 0; i < q; i++) {
    long long k1, k2;
    if (s[i][0] == 1) {
      k1 = (s[i][1] + (n / g) - 1) / (n / g);
    } else
      k1 = (s[i][1] + (m / g) - 1) / (m / g);
    if (s[i][2] == 1) {
      k2 = (s[i][3] + (n / g) - 1) / (n / g);
    } else
      k2 = (s[i][3] + (m / g) - 1) / (m / g);
    if (k1 == k2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
