#include <bits/stdc++.h>
using namespace std;
void rng_10s() {
  int T;
  cin >> T;
  for (size_t i = 0; i < T; i++) {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    map<long long, bool> m;
    m[A] = true;
    for (;;) {
      long long rem = A / B;
      if (rem == 0) {
        cout << "No"
             << "\n";
        break;
      }
      A -= (rem * B);
      if (A <= C) {
        A += D;
        if (m[A]) {
          cout << "Yes"
               << "\n";
          break;
        }
      }
      m[A] = true;
    }
  }
}
int main() {
  rng_10s();
  return 0;
}
