#include <bits/stdc++.h>
using namespace std;
const int inft = 1000000009;
const int mod = 1000000007;
const int MAXN = 1000006;
int h;
bool solve(int p, int a, int n, bool last) {
  ;
  if (h == 0) return 0;
  if (1LL * a * n < p) {
    if (!last) return h >= a;
    return h >= a && h >= (p - n * a);
  }
  if (a == 1) {
    if (n >= p) return 1;
    if (last) return p - n <= h;
    return 1;
  }
  if (n == 0) return !last;
  int first = p / a;
  int del = 1LL * (first + 1) * a % p;
  if (1LL * n * a % p + a >= p - p % a) {
    return solve(a, del, 1LL * n * a / p, 1);
  }
  return solve(a, del, 1LL * n * a / p - 1, 1);
}
int main() {
  int te = 1;
  scanf("%d", &te);
  for (int ti = 0; ti < (te); ++ti) {
    int a, n, p;
    scanf("%d%d%d%d", &a, &n, &p, &h);
    puts(solve(p, a % p, n, 0) ? "YES" : "NO");
  }
  return 0;
}
