#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);
}
long long ceill(long long a, long long b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
int main() {
  long long n, m, q;
  cin >> n >> m >> q;
  long long hcf = gcd(n, m);
  n /= hcf;
  m /= hcf;
  while (q--) {
    long long sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    if (sx == 1 && ex == 1) {
      if (ceill(sy, n) == ceill(ey, n))
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else if (sx == 2 && ex == 2) {
      if (ceill(sy, m) == ceill(ey, m))
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else if (sx == 1 && ex == 2) {
      if (ceill(sy, n) == ceill(ey, m))
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else {
      if (ceill(sy, m) == ceill(ey, n))
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
}
