#include <bits/stdc++.h>
using namespace std;
unsigned long long int isOut(unsigned long long int now,
                             unsigned long long int a,
                             unsigned long long int b) {
  if (a > now && now > b)
    return 1;
  else
    return 0;
}
unsigned long long int isOut2(unsigned long long int now,
                              unsigned long long int a,
                              unsigned long long int b) {
  if (a > now)
    return 1;
  else
    return 0;
}
unsigned long long int distract(unsigned long long int now,
                                unsigned long long int border,
                                unsigned long long int buy) {
  if (now <= border) {
    if (now < buy)
      return now;
    else
      return now - buy;
  }
  if ((now - border) % buy == 0) {
    return border;
  } else {
    if (now < ((now - border) / buy + 1) * buy) {
      return now - ((now - border) / buy) * buy;
    }
    return now - ((now - border) / buy + 1) * buy;
  }
}
int main() {
  unsigned long long int t;
  cin >> t;
  for (int xxxxx = 0; xxxxx < t; xxxxx++) {
    unsigned long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    unsigned long long int now = a;
    unsigned long long int flag = 0;
    unsigned long long int first = 0;
    unsigned long long int min = 1000000000000000;
    set<unsigned long long int> flg;
    while (1) {
      first = 0;
      flag = 0;
      if (0) cout << "now=" << now << endl;
      if (isOut2(now, b, c)) {
        flag = 1;
        break;
      }
      now = distract(now, c, b);
      if (0) cout << "afterNow=" << now << endl;
      if (isOut(now, b, c)) {
        flag = 1;
        break;
      }
      now += d;
      if (flg.count(now) == 0) {
        if (0) cout << now << endl;
        flg.insert(now);
      } else {
        break;
      }
    }
    if (flag)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
