Code: Grid Covering
// 2217C - Grid Covering
#include <bits/stdc++.h>
using namespace std;
static long long gcdll(long long a, long long b) {
while (b != 0) {
long long t = a % b;
a = b;
b = t;
}
return a;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
long long n, m, a, b;
cin >> n >> m >> a >> b;
bool ok = true;
ok &= (gcdll(n, a) == 1);
ok &= (gcdll(m, b) == 1);
ok &= (gcdll(n, m) <= 2);
cout << (ok ? "YES" : "NO") << '\n';
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
void solve() {
ll N, M, A, B;
cin >> N >> M >> A >> B;
if (gcd(N, A) > 1 || gcd(M, B) > 1) {
cout << "NO" << '\n';
return;
}
if (gcd(N, M) > 2) {
cout << "NO" << '\n';
return;
}
cout << "YES" << '\n';
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int T;
cin >> T;
while (T--)
solve();
}