#include <bits/stdc++.h>
long long read() {
  char c = getchar();
  long long ans = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
  return ans;
}
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x < y ? x : y; }
long long get_ans(long long a, long long n, long long p) {
  if (a * n < p) return max(a, p - a * n);
  return get_ans(min(p % a, a - p % a),
                 a * n / p - (a * n % p < a * (p / a - 1)), a);
}
int main() {
  long long t = read(), a, n, p, h;
  while (t--) {
    a = read(), n = read(), p = read(), h = read();
    a %= p;
    printf("%s\n", (a * n < p ? a : get_ans(a, n, p)) > h ? "NO" : "YES");
  }
  return 0;
}
