#include <bits/stdc++.h>
int main(int argc, char* argv[]) {
  int t;
  std::vector<long long> a, b, c, d;
  std::cin >> t;
  a.reserve(t);
  b.reserve(t);
  c.reserve(t);
  d.reserve(t);
  for (int i = 0; i < t; i++) {
    long long a_i, b_i, c_i, d_i;
    std::cin >> a_i >> b_i >> c_i >> d_i;
    a.push_back(a_i);
    b.push_back(b_i);
    c.push_back(c_i);
    d.push_back(d_i);
  }
  for (int i = 0; i < t; i++) {
    long long s = a[i];
    std::vector<long long> ss;
    while (1) {
      long long n;
      if (s < b[i]) {
        std::cout << "No" << std::endl;
        break;
      }
      if (s < c[i]) {
        n = 0;
      } else if ((s - c[i]) % b[i] == 0) {
        n = (s - c[i]) / b[i];
      } else {
        n = (s - c[i]) / b[i] + 1;
      }
      s -= b[i] * n;
      if (s < 0) {
        std::cout << "No" << std::endl;
        break;
      }
      s += d[i];
      if (ss.empty()) {
        ss.push_back(s);
      } else if (std::find(ss.begin(), ss.end(), s) != ss.end()) {
        ss.clear();
        std::cout << "Yes" << std::endl;
        break;
      } else {
        ss.push_back(s);
      }
    }
  }
  return 0;
}
