#include <bits/stdc++.h>   using namespace std;   const int maxn = 200;   int h[maxn];   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   int main() {     long long n, m, sx, sy, ex, ey;     int q;     scanf( %lld%lld%d , &n, &m, &q);     long long gc = gcd(n, m);     long long stp1 = n / gc, stp2 = m / gc;     long long num1, num2;     while (q--) {       scanf( %lld%lld%lld%lld , &sx, &sy, &ex, &ey);       num1 = num2 = 0;       if (sx == 1) {         num1 = sy / stp1;         if (sy % stp1 != 0) num1++;       } else {         num1 = sy / stp2;         if (sy % stp2 != 0) num1++;       }       if (ex == 1) {         num2 = ey / stp1;         if (ey % stp1 != 0) num2++;       } else {         num2 = ey / stp2;         if (ey % stp2 != 0) num2++;       }       if (num1 == num2)         printf( YES n );       else         printf( NO n );     }     return 0;   }   