#include <bits/stdc++.h>
using namespace std;
using namespace std;
map<pair<pair<double, double>, pair<double, double> >, bool> mp;
int main() {
  std::ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  long long a, b, c, d;
  while (t--) {
    cin >> a >> b >> c >> d;
    long long tt = a;
    int ops = 0;
    unordered_set<long long> seen(100000001 / 3);
    bool bad = 0;
    if (mp.find(make_pair(pair<double, double>(a, b),
                          pair<double, double>(c, d))) != mp.end()) {
      if (mp[make_pair(pair<double, double>(a, b),
                       pair<double, double>(c, d))]) {
        cout << "Yes\n";
      } else {
        cout << "No\n";
      }
      continue;
    }
    while (a > 0) {
      seen.insert(a);
      if (a < b) break;
      long long r = max(0LL, (a - c)) / b;
      if (max(0LL, (a - c)) % b != 0) {
        ++r;
      }
      if (r == 0) ++r;
      a -= 1ll * r * b;
      if (a < 0) break;
      a += 1ll * d;
      if (seen.find(a) != seen.end()) {
        bad = 1;
        break;
      }
      ++ops;
    }
    if (!bad) {
      cout << "No\n";
      mp[make_pair(pair<double, double>(tt, b), pair<double, double>(c, d))] =
          0;
    } else {
      mp[make_pair(pair<double, double>(tt, b), pair<double, double>(c, d))] =
          1;
      cout << "Yes\n";
    }
  }
}
