#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b, long long res);
int main() {
  long long n, m, q;
  long long c = 1;
  cin >> n >> m >> q;
  long long g = gcd(n, m, c);
  long long nd = n / g;
  long long md = m / g;
  for (int i = 0; i < q; i++) {
    long long a, b, c, d, e, f;
    cin >> a >> b >> c >> d;
    b--;
    d--;
    if (a == 1)
      e = b / nd;
    else
      e = b / md;
    if (c == 1)
      f = d / nd;
    else
      f = d / md;
    if (e == f)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
long long gcd(long long a, long long b, long long res) {
  if (a == b)
    return a * res;
  else if (a % 2 == 0 && b % 2 == 0) {
    a /= 2;
    b /= 2;
    return gcd(a, b, res * 2);
  } else if (a % 2 == 0) {
    a /= 2;
    return gcd(a, b, res);
  } else if (b % 2 == 0) {
    b /= 2;
    return gcd(a, b, res);
  } else if (a > b) {
    return gcd(a - b, b, res);
  } else {
    return gcd(b - a, a, res);
  }
}
