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