#include <bits/stdc++.h>
using namespace std;
int T, a, n, p, h;
int solve(int n, int a, int p) {
  if (1LL * a * n < p)
    return max(a, p - a * n);
  else
    return solve(1LL * a * n / p - (1LL * a * n % p < (p / a - 1) * a), p % a,
                 a);
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d%d", &a, &n, &p, &h);
    a %= p;
    int ans;
    if (1LL * a * n < p)
      ans = a;
    else
      ans = solve(n, a, p);
    puts(ans <= h ? "YES" : "NO");
  }
  return 0;
}
