#include <bits/stdc++.h>
using namespace std;
long long t, a, n, p, h;
inline long long Read() {
  long long x = 0;
  char y;
  do y = getchar();
  while (y < '0' || y > '9');
  do x = x * 10 + y - '0', y = getchar();
  while (y >= '0' && y <= '9');
  return x;
}
inline long long max(long long x, long long y) { return x < y ? y : x; }
long long GetAns(long long x, long long y, long long z) {
  return x * (y - 1) > z ? GetAns(z % x, (x * y + z % x) / z, x)
                         : max(x, z - x * (y - 1));
}
int main() {
  t = Read();
  while (t--)
    a = Read(), n = Read(), p = Read(), h = Read(), a %= p,
    puts((a * n < p ? a : GetAns(a, n + 1, p)) <= h ? "YES" : "NO");
  return 0;
}
