#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int sz = 1 << 15;
char inbuf[sz], outbuf[sz];
char *pinbuf = inbuf + sz;
char *poutbuf = outbuf;
inline char _getchar() {
  if (pinbuf == inbuf + sz) fread(inbuf, 1, sz, stdin), pinbuf = inbuf;
  return *(pinbuf++);
}
inline void _putchar(char x) {
  if (poutbuf == outbuf + sz) fwrite(outbuf, 1, sz, stdout), poutbuf = outbuf;
  *(poutbuf++) = x;
}
inline void flush() {
  if (poutbuf != outbuf)
    fwrite(outbuf, 1, poutbuf - outbuf, stdout), poutbuf = outbuf;
}
}  // namespace IO
inline int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = v * 10 + c - '0';
    c = getchar();
  }
  return v * f;
}
int Solve(int a, int n, int p) {
  a %= p;
  if (1ll * n * a < (long long)p) return max(a, p - a * n);
  int A = p % a, P = a, N = 1ll * n * a / p;
  int tt = 1ll * n * a % p;
  if (tt < (p / a - 1) * a) N--;
  return Solve(A, N, P);
}
void mian() {
  int a, n, p, h;
  a = read();
  n = read();
  p = read();
  h = read();
  a %= p;
  int x;
  if (1ll * a * n < p) {
    x = a;
  } else
    x = Solve(a, n, p);
  if (x <= h) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    mian();
  }
}
