#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long n, m;
  int q;
  cin >> n >> m >> q;
  while (q--) {
    long long a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    long long k = gcd(n, m);
    --b;
    --d;
    long long num1 = n / k, num2 = m / k;
    long long pos1 = 0, pos2 = 0;
    if (a == 1)
      pos1 = b / num1;
    else
      pos1 = b / num2;
    if (c == 1)
      pos2 = d / num1;
    else
      pos2 = d / num2;
    if (pos1 == pos2)
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}
