#include <bits/stdc++.h>
using namespace std;
long long __gcd(long long gcd, long long x) {
  long long Min = min(gcd, x);
  long long Max = max(gcd, x);
  while (Max % Min != 0) {
    long long m = Min;
    Min = Max % Min;
    Max = m;
  }
  return Min;
}
int main() {
  long long n, m, q;
  cin >> n >> m >> q;
  long long parts = __gcd(n, m);
  for (long long i = 0; i < q; i++) {
    long long sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    if (parts == 1)
      cout << "YES" << endl;
    else {
      long long p1 = n / parts, p2 = m / parts;
      long long c, d;
      if (sx == 1) {
        if (sy % p1 == 0)
          c = sy / p1;
        else
          c = (sy / p1) + 1;
      } else {
        if (sy % p2 == 0)
          c = sy / p2;
        else
          c = (sy / p2) + 1;
      }
      if (ex == 1) {
        if (ey % p1 == 0)
          d = ey / p1;
        else
          d = (ey / p1) + 1;
      } else {
        if (ey % p2 == 0)
          d = ey / p2;
        else
          d = (ey / p2) + 1;
      }
      if (c == d)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
