#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  long long int r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
int main() {
  long long int n, m;
  long long int q, sx, sy, ex, ey;
  cin >> n >> m >> q;
  long long int k = gcd(n, m);
  long long int x = n / k;
  long long int y = m / k;
  while (q--) {
    cin >> sx >> sy >> ex >> ey;
    long long int ans1, ans2;
    if (sx == 1)
      ans1 = (sy % x == 0) ? (sy - 1) / x : sy / x;
    else
      ans1 = (sy % y == 0) ? (sy - 1) / y : sy / y;
    if (ex == 2)
      ans2 = (ey % y == 0) ? (ey - 1) / y : ey / y;
    else
      ans2 = (ey % x == 0) ? (ey - 1) / x : ey / x;
    if (ans1 == ans2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
