#include <bits/stdc++.h>
template <typename T>
void checkmin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
void checkmax(T &a, T b) {
  if (a < b) a = b;
}
bool solve(long long a, long long n, long long p, long long h, bool ceil = 0) {
  if (a * n < p) return a <= h && (!ceil || p - a * n <= h);
  if (2 * a > p) return solve(p - a, n, p, h, 1);
  long long s = p / a - 1;
  long long p2 = p % a + a;
  long long n2 = n - (n * a / p * s + std::min(n * a % p / a + 1, s));
  return solve(a, n2, p2, h, ceil);
}
void run() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a, n, p, h;
    scanf("%d%d%d%d", &a, &n, &p, &h);
    a %= p;
    puts(solve(a, n, p, h) ? "YES" : "NO");
  }
}
void brute(int a, int n, int p, int h) {
  std::vector<int> A;
  for (int i = 0; i < (n + 1); ++i) A.push_back(a * n % p);
}
int main() {
  run();
  return 0;
}
