#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long int n, m, q;
  cin >> n >> m >> q;
  long long int g = gcd(n, m);
  long long int n1 = n / g, m1 = m / g;
  for (long long int i = 0; i < q; i++) {
    long long int sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    sy--, ey--;
    long long int t1, t2;
    if (sx == 1)
      t1 = sy / n1;
    else
      t1 = sy / m1;
    if (ex == 1)
      t2 = ey / n1;
    else
      t2 = ey / m1;
    if (t1 == t2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
