#include <bits/stdc++.h>
using namespace std;
const long long int inf = 2222222222222222222LL;
const long long int mod = 1000000007LL;
const double pi = acos(-1);
const double eps = 1e-10;
long long int n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
long long int dx[5] = {1, -1, 0, 0, 0}, dy[5] = {0, 0, 1, -1, 0};
long long int ddx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0},
              ddy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
int main(void) {
  long long int t, a, b, c, d;
  cin >> t;
  for (long long int i = (long long int)(0LL); i < (long long int)(t); i++) {
    cin >> a >> b >> c >> d;
    map<long long int, long long int> mp;
    long long int pre, y = 0;
    mp[a]++;
    while (1) {
      if (a < b) {
        ok = false;
        break;
      }
      pre = a;
      tmp = a / b;
      if (tmp > 2 && a > c) {
        tmp -= (c + b - 1) / b;
        a -= b * tmp;
      } else
        a -= b;
      flag = false;
      if (a <= c) a += d;
      if (pre < a) {
        long long int x = a - pre;
        a += ((c + d) - a + b - 1) / b * x;
        if (y) {
          long long int z = pre - y;
          a = pre + ((b + c - pre + z - 1) / z) * z - b;
          flag = true;
        }
        y = pre;
      }
      if (flag && a <= c) a += d;
      cout << a << endl;
      if (mp[a]) {
        ok = true;
        break;
      }
      if (cnt > 10000) {
        ok = true;
        break;
      }
      mp[a]++;
      cnt++;
    }
    if (ok)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
