#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  long long a[t], b[t], c[t], d[t];
  for (int i = 0; i < t; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
  for (int i = 0; i < t; i++) {
    long long p = d[i] - b[i];
    if (d[i] - b[i] < 0) {
      cout << "No" << endl;
      continue;
    }
    long long m = b[i];
    long long at = a[i] - b[i];
    long long ct = c[i];
    if (at < 0) {
      cout << "No" << endl;
      continue;
    }
    long long g = gcd(p, m);
    cout << g << endl;
    long long cm = -1;
    if (at <= ct) {
      cm = at + ((ct - at) / g + 1) * g;
    } else {
      if ((at - ct) % g == 0)
        cm = at - ((at - ct) / g - 1) * g;
      else
        cm = at - ((at - ct) / g) * g;
    }
    if (cm - m >= 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
