#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
void print(vector<long long> &a) {
  int n = a.size();
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
void print(vector<int> &a) {
  int n = a.size();
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    long long n, m, q;
    cin >> n >> m >> q;
    long long qs = gcd(n, m);
    long long qn = n / qs, qm = m / qs;
    while (q--) {
      long long sx, sy, ex, ey;
      cin >> sx >> sy >> ex >> ey;
      long long quarx, quary;
      if (sx == 1)
        quarx = (sy - 1) / qn;
      else
        quarx = (sy - 1) / qm;
      if (ex == 1)
        quary = (ey - 1) / qn;
      else
        quary = (ey - 1) / qm;
      if (quarx == quary)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
