#include <bits/stdc++.h>
using namespace std;
long long int lcm(long long int a, long long int b) {
  if (b == 0) return a;
  return lcm(b, a % b);
}
int main() {
  long long int n, q, m;
  cin >> n >> m >> q;
  long long int gcd = lcm(n, m);
  long long int temp1 = n / gcd;
  long long int temp2 = m / gcd;
  for (long long int i = 0; i < q; i++) {
    long long int sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    long long int box1 = 0;
    long long int box2 = 0;
    if (sx == 1) box1 = (sy - 1) / temp1;
    if (sx == 2) box1 = ((sy - 1) / temp2);
    if (ex == 1) box2 = ((ey - 1) / temp1);
    if (ex == 2) box2 = ((ey - 1) / temp2);
    if (box1 == box2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
