#include <bits/stdc++.h>
using namespace std;
const long long M = 1e6 + 5;
long long read() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') y = (ch == '-' ? -1 : 1), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * y;
}
long long Get(long long a, long long n, long long p) {
  return a * n < p
             ? max(a, p - a * n)
             : Get(a - p % a, a * n / p - (a * n % p < a * (p / a - 1)), a);
}
void solve() {
  long long a = read(), n = read(), p = read(), h = read();
  a %= p;
  printf("%s\n", (a * n < p ? a : Get(a, n, p)) > h ? "NO" : "YES");
}
signed main() {
  long long T = read();
  while (T--) solve();
}
