#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long delvverx(long long a, long long b) {
  if (a % b == 0) {
    return (a / b);
  } else {
    return (a / b + 1);
  }
}
vector<long long> rs;
int main() {
  long long n, m, q, x, y, a, b;
  cin >> n >> m >> q;
  long long d = gcd(n, m);
  rs.resize(3);
  rs[1] = n / d;
  rs[2] = m / d;
  for (int i = 0; i < q; i++) {
    cin >> x >> y >> a >> b;
    if (x != a) {
      if (delvverx(y, rs[x]) == delvverx(b, rs[a])) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    } else {
      if (x == 1) {
        if (delvverx(y, rs[x]) == delvverx(b, rs[x])) {
          cout << "YES\n";
        } else {
          cout << "NO\n";
        }
      } else {
        if (delvverx(y, rs[x]) == delvverx(b, rs[x])) {
          cout << "YES\n";
        } else {
          cout << "NO\n";
        }
      }
    }
  }
  return 0;
}
