#include <bits/stdc++.h>
using namespace std;
long long count_nod(long long a, long long b) {
  while (a != 0 && b != 0) {
    if (a > b)
      a %= b;
    else
      b %= a;
  }
  return max(a, b);
}
long long count_nok(long long nod, long long a, long long b) {
  return (a * (b / nod));
}
int main() {
  long long t, n, m, k, sx, sy, ex, ey, z1, z2, c = 1;
  cin >> n >> m >> t;
  long long nod = count_nod(n, m);
  for (int i = 0; i < t; i++) {
    cin >> sx >> sy >> ex >> ey;
    if (sx == 1)
      z1 = n;
    else
      z1 = m;
    if (ex == 1)
      z2 = n;
    else
      z2 = m;
    z1 /= nod;
    z2 /= nod;
    if ((sy - 1) / z1 == (ey - 1) / z2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
