#include <bits/stdc++.h>
using namespace std;
long long n, m, q, g;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long group(int a, long long b) {
  if (a == 1) {
    return (b + (n / g) - 1) / (n / g);
  }
  return (b + (m / g) - 1) / (m / g);
}
int main() {
  scanf("%lld%lld%lld", &n, &m, &q);
  g = gcd(n, m);
  long long sx, sy, ex, ey;
  for (int i = 1; i <= q; i++) {
    scanf("%lld%lld%lld%lld", &sx, &sy, &ex, &ey);
    group(sx, sy) == group(ex, ey) ? printf("Yes\n") : printf("No\n");
  }
}
