using ll=long long;
#include<limits>
namespace pcl{constexpr int INF=std::numeric_limits<int>::max()/2;constexpr ll LNF=std::numeric_limits<ll>::max()/2;constexpr double DNF=std::numeric_limits<double>::max()/2;constexpr double EPS=1e-8;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}inline bool eqdbl(double a,double b){return std::abs(a-b)<EPS;}inline bool ledbl(double a,double b){return a<b||eqdbl(a,b);}inline bool gtdbl(double a,double b){return a>b||eqdbl(a,b);}}
#include<iostream>
#include<string>
namespace pcl{template<typename Printer>void _assert_failed(char const*expr,Printer showmsg,char const*file,unsigned line){std::cerr<<"!!!!!Assertion Failed!!!!!"<<std::endl;std::cerr<<"--->`"<<expr<<"` at "<<file<<",line "<<line<<std::endl;showmsg();abort();}
#define DEFINE_ASSERT_XX(xx,cond_op)\
template<typename T,typename U>\
void _assert_##xx(char const*expr1_str,char const*expr2_str,\
T const&expr1,U const&expr2,char const*msg,\
char const*file,unsigned line){\
if(!(expr1 cond_op expr2)){\
std::string es=\
std::string(expr1_str)+" " #cond_op " "+expr2_str;\
auto printer=[&](){\
if(msg[0]!=0)std::cerr<<"|"<<msg<<std::endl;\
std::cerr<<"|left:"<<expr1<<std::endl;\
std::cerr<<"|right:"<<expr2<<std::endl;\
};\
_assert_failed(es.c_str(),printer,file,line);\
}\
}
DEFINE_ASSERT_XX(eq,==)DEFINE_ASSERT_XX(ne,!=)DEFINE_ASSERT_XX(gt,>)DEFINE_ASSERT_XX(lt,<)DEFINE_ASSERT_XX(ge,>=)DEFINE_ASSERT_XX(le,<=)template<typename T,typename U,typename V>void _assert_range(T const&begin,char const*mid_str,U const&mid,V const&end,char const*msg,char const*file,unsigned line){if(!in_range(begin,mid,end)){std::string es="";es+=std::to_string(begin)+"<="+mid_str+"("+std::to_string(mid)+")<"+std::to_string(end);auto printer=[&](){std::cerr<<"|variable is not in range."<<std::endl;if(msg[0]!=0)std::cerr<<"|"<<msg<<std::endl;};_assert_failed(es.c_str(),printer,file,line);}}
#undef DEFINE_ASSERT_XX
}
#ifdef NOASSERT
#define ASSERT(...)
#define ASSERT_RANGE(...)
#define ASSERT_EQ(...)
#define ASSERT_NE(...)
#define ASSERT_GT(...)
#define ASSERT_LT(...)
#define ASSERT_GE(...)
#define ASSERT_LE(...)
#else
#define ASSERT(expr,msg)\
(void)(!(expr)&&(pcl::_assert_failed(#expr,\
[&](){\
if((msg)[0]!=0)\
std::cerr<<"|"<<msg \
<<std::endl;\
},\
__FILE__,__LINE__),\
0))
#define ASSERT_RANGE(begin,mid,end,msg)\
pcl::_assert_range(begin,#mid,mid,end,msg,__FILE__,__LINE__)
#define CALL_ASSERT_XX(xx,expr1,expr2,msg)\
pcl::_assert_##xx(#expr1,#expr2,expr1,expr2,msg,__FILE__,__LINE__)
#define ASSERT_EQ(expr1,expr2,msg)CALL_ASSERT_XX(eq,expr1,expr2,msg)
#define ASSERT_NE(expr1,expr2,msg)CALL_ASSERT_XX(ne,expr1,expr2,msg)
#define ASSERT_GT(expr1,expr2,msg)CALL_ASSERT_XX(gt,expr1,expr2,msg)
#define ASSERT_LT(expr1,expr2,msg)CALL_ASSERT_XX(lt,expr1,expr2,msg)
#define ASSERT_GE(expr1,expr2,msg)CALL_ASSERT_XX(ge,expr1,expr2,msg)
#define ASSERT_LE(expr1,expr2,msg)CALL_ASSERT_XX(le,expr1,expr2,msg)
#endif
#ifdef PA_DEBUG
#define PD(stmt)stmt
#else
#define PD(stmt)
#endif
#ifdef PA_DEBUG_LIB
#define PD_LIB(stmt)stmt
#else
#define PD_LIB(stmt)
#endif
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<cmath>
#include<utility>
#include<vector>
namespace pcl{template<typename T>constexpr T gcd(T a,T b){return b==0?a:gcd(b,a%b);}template<typename T>constexpr T lcm(T a,T b){return a/gcd(a,b)*b;}template<typename T>constexpr T extgcd(T a,T b,T&xd,T&yd){if(b==0){xd=1,yd=0;return a;}T gcd=extgcd(b,a%b,yd,xd);yd-=(a/b)*xd;return gcd;}template<typename T>std::vector<T>sieve(T N){std::vector<T>result;std::vector<bool>is_not_prime(N);for(T i=2;i<=N;i++){if(is_not_prime[i])continue;result.push_back(i);for(T j=i+i;j<=N;j+=i)is_not_prime[j]=true;}return result;}template<typename T>constexpr T pow(T x,int n){T result=1;while(n>0){if(n&1)result*=x;x*=x;n>>=1;}return result;}template<typename T>constexpr bool is_prime(T val){for(T i=2;i<val;i++){if(val%i==0)return false;}return true;}}
#define NO{cout<<"No"<<endl;continue;}
#define YES{cout<<"Yes"<<endl;continue;}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;inline ll first(ll a,ll b){return(b+(a-1))/a*a;}int main(){int T;cin>>T;for(int q=0;q<T;q++){ll a,b,c,d;cin>>a>>b>>c>>d;ll r=a-c;ll over=first(b,r)-r;ll x=d-b;if(b>d){NO}else if(b==d){if(r<0){if(a<b){NO}else{YES}}else{if(over>c){NO}else{YES}}}else if(b<d){if(r<0){if(a<b){NO}else{r=first(x,-r)+r;}}else{}ASSERT_GT(x,0,"");r%=b;ll g=gcd(x,b);r%=g;if(r==0)r=g;if(c+r>=b){YES}else{NO}}else{assert(false);}}}

Measured memory_bytes: 256