#include <bits/stdc++.h>
using namespace std;
inline int Get() {
  int res = 0, q = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') q = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return res * q;
}
const double eps = 1e-12, pi = M_PI;
const int oo = (int)2e9, mod = (int)1e9 + 7;
const long long INF = (long long)1e17;
int T;
long long a, n, p, h;
long long Calc(long long a, long long n, long long p) {
  long long rd = a * n / p;
  if (!rd) return ((a) > (p - a * n) ? (a) : (p - a * n));
  long long dt = a * n % p, st = p - p % a - a;
  if (dt < st) --rd;
  return Calc(min(a - p % a, p % a), rd, a);
}
int main() {
  for (scanf("%d"
             "\n",
             &T);
       T--;) {
    scanf(
        "%I64d"
        "%I64d"
        "%I64d"
        "%I64d"
        "\n",
        &a, &n, &p, &h),
        a %= p;
    if (a * n < p)
      printf("%s\n", a <= h ? "YES" : "NO");
    else
      printf("%s\n", Calc(a, n, p) <= h ? "YES" : "NO");
  }
  return 0;
}
