#include <bits/stdc++.h>
using namespace std;
long long calc(long long a, long long n, long long p) {
  long long m = a * n / p;
  if (!m) return max(a, p - a * n);
  if (a * n % p < (p / a - 1) * a) --m;
  return m ? calc(min(p % a, p - p % a), m, a) : a;
}
int main() {
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    long long a, n, p, h;
    cin >> a >> n >> p >> h;
    a %= p;
    if ((a * n < p ? a : calc(a, n, p)) > h)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
}
