#include <bits/stdc++.h>
using namespace std;
int get(long long a, long long n, long long p) {
  return a * n <= p ? max(a, p - a * n)
                    : get(p % a, (n * a + p % a + a) / p - 1, a);
}
int T;
long long a, n, p, h;
signed main() {
  for (cin >> T; T; --T) {
    cin >> a >> n >> p >> h, a %= p;
    puts((a * n <= p ? a : get(a, n, p)) > h ? "NO" : "YES");
  }
  return 0;
}
