#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


tuple<Int,Int,Int,Int>  sim1(Int A,Int B,Int C,Int D){
  auto get =[&](){return ((A-C-1)/B);};
  if(A - B > C) A = A - B * get();
  A -= B;
  if(A < 0) return make_tuple(-1,-1,-1,-1);
  if(A <= C) A += D;
  if(A - B > C) A = A - B * get();
  return make_tuple(A,B,C,D);
}


Int sim(Int A,Int B,Int C,Int D){
  set<Int> S;
  Int pre = -1;
  Int d = -1;
  vector<Int> X;
  while(1){
    tie(A,B,C,D) = sim1(A,B,C,D);
    if(A < 0) return 0;
    if(A - C < 0) return 0;
    if(X.size() >1000) return 1;
    if(pre != -1 && d != -1){
      Int d = (abs(A-C) - pre + D)%D;
      if(d == 0) return 1;
      //pr(d);
      Int x = (A-C)%d;
      if(X.size() >= 2){
	if(X[0] < X[1]) return 1;
	Int d2 = X[0] - X[1];
	x = x - d*((x-1)/d2);
      }
      A = x + A;
      S.insert(x);
      pre = d = -1;
    }
    pre = A-C;
    if(S.count(A-C)) return 1;
    S.insert(A-C);

  }
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int Q;
  cin>>Q;
  while(Q--){
    Int A,B,C,D;
    cin>>A>>B>>C>>D;
    Int ans = sim(A,B,C,D);
    cout<<(ans? "Yes":"No")<<endl;

    
  }
  return 0;
}
