#include <bits/stdc++.h>
using namespace std;
const int mod = 20100403;
long long n, m, q, num, len1, len2;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  cin >> n >> m >> q;
  num = gcd(n, m);
  len1 = n / num;
  len2 = m / num;
  while (q--) {
    long long sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    if (sx == 1) sy = (sy - 1) / len1;
    if (sx == 2) sy = (sy - 1) / len2;
    if (ex == 1) ey = (ey - 1) / len1;
    if (ex == 2) ey = (ey - 1) / len2;
    if (sy == ey)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
