#include <bits/stdc++.h>
using namespace std;
map<long long, bool> mp;
long long a, b, c, d, la;
int i, j, k, n, m, x, y, t, T;
int main() {
  scanf("%d", &T);
  while (T--) {
    mp.clear();
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    long long p = (a - c) / b;
    p = a - p * b;
    if (p > c) p -= b;
    while (p >= 0 && !mp[p]) {
      mp[p] = 1;
      if (p <= c) p += d;
      if (p < c)
        p -= b;
      else
        p = p - ((p - c) / b) * b;
      if (p > c) p -= b;
    }
    if (p < 0)
      printf("NO\n");
    else
      printf("YES\n");
  }
}
