#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    double A, B, C, D;
    scanf("%lf%lf%lf%lf", &A, &B, &C, &D);
    if (A < B) {
      printf("NO\n");
      continue;
    }
    set<double> vis;
    while (true) {
      vis.insert(A);
      A -= max(1.0, ceil((A - C) / B)) * B;
      if (A < 0) {
        printf("NO\n");
        break;
      }
      if (A <= C) A += D;
      if (vis.count(A)) {
        printf("YES\n");
        break;
      }
    }
  }
  return 0;
}
