#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  long long T, A, B, C, D;
  cin >> T;
  vector<string> ans;
  for (int i = 0; i < (T); i++) {
    set<long long> st;
    cin >> A >> B >> C >> D;
    if (D < B) {
      ans.push_back("No");
      continue;
    }
    if (A < B) {
      ans.push_back("No");
      continue;
    }
    if (B == 1) {
      ans.push_back("Yes");
      continue;
    }
    if (C >= B) {
      ans.push_back("Yes");
      continue;
    }
    long long now = A % B;
    long long add = D % B;
    if (now > C) {
      ans.push_back("No");
      continue;
    }
    if (add == 0) {
      ans.push_back("Yes");
      continue;
    }
    long long dis = B - now;
    long long t = dis / add;
    long long last = now + t * add;
    cout << last << endl;
    if (last == B) last -= add;
    if (last > C)
      ans.push_back("No");
    else
      ans.push_back("Yes");
  }
  for (auto x : ans) cout << x << endl;
}
