#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
int main() {
  ios::sync_with_stdio(0);
  long long n, m, q, x1, x2, s1, s2;
  cin >> n >> m >> q;
  long long g = gcd(n, m);
  n = n / g, m = m / g;
  long long tp;
  while (q--) {
    cin >> x1 >> s1 >> x2 >> s2;
    s1--, s2--;
    if (g == 1) {
      printf("YES\n");
      continue;
    }
    x1 == 1 ? tp = n : tp = m;
    s1 = s1 / tp;
    x2 == 1 ? tp = n : tp = m;
    s2 = s2 / tp;
    if (s1 == s2)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
