#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long int t, n, m;
  cin >> n >> m >> t;
  long long int k = gcd(n, m);
  long long int k1 = n / k, k2 = m / k;
  while (t--) {
    long long int sx, sy, ex, ey, s, e;
    cin >> sx >> sy >> ex >> ey;
    if (sx == 1)
      s = (sy - 1) / k1;
    else
      s = (sy - 1) / k2;
    if (ex == 1)
      e = (ey - 1) / k1;
    else
      e = (ey - 1) / k2;
    if (s == e)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
