#include <bits[表情]dc++.h>
using namespace std;
#define debug(x) cerr << #x << " == " << x << endl
#define el '\n'
typedef long long ll;
const int mod = 1000000007;
const int inf = 2147483647;
const int N = 200020;
void solve()
{
int A, B, x, y;
cin >> x >> y >> A >> B;
A = min(A, x), B = min(B, y);
if (x == y) {
cout << "YES\n";
cout << "2 2\n";
return;
}
if (x == 1 || y == 1) {
cout << "NO" << el;
return;
}
map<vector<int>, int> mp;
for (int i = 2; i * i <= x && i <= A; i++) {
// x->i
int now = x;
vector<int> s;
while (now >= 1) {
s.push_back(now % i);
now = now / i;
}
mp[s] = i;
}
for (int i = 2; i * i <= y && i <= B; i++) {
// x->i
int now = y;
vector<int> s;
while (now >= 1) {
s.push_back(now % i);
now = now / i;
}
if (mp.find(s) != mp.end()) {
cout << "YES" << el;
cout << mp[s] << " " << i << el;
return;
}
}
int flag = 0;
if (x < y) {
swap(x, y);
swap(A, B);
flag = 1;
}
int a, b;
int minb = sqrt(y) + 1;
int mina = sqrt(x) + 1;
for (int p = 1; p * p < x && p * p < y; p++) {
if ((x - y) % p != 0)
continue;
int res = (x - y) / p;
a = min(A, x / p);
b = min(B, y / p);
if (a - res <= b)
b = a - res;
else
a = b + res;
if (a < mina || b < minb)
continue;
int q = x - a * p;
if (q < a && q < b) {
cout << "YES" << el;
if (flag)
swap(a, b);
cout << a << " " << b << el;
return;
}
}
cout << "NO" << el;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}