#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const double eps = 1e-9;
bool go(int a, int n, int p, int h) {
  if (h == 0) return false;
  if (a * 2 > p) return go(p - a, n, p, h);
  if (p <= h) return true;
  if (n < p / a) return p - n * a <= h;
  if (a == 1) return true;
  int a1 = p % a;
  int n1 = ((n + 1) * (long long)a - p + a1 - 1) / p;
  return go(a1, n1, a, h);
}
int main() {
  int tn;
  scanf("%d", &tn);
  for (int tt = 0; (tt) < (tn); ++tt) {
    int a, n, p, h;
    scanf("%d%d%d%d", &a, &n, &p, &h);
    a = a % p;
    bool res;
    if (n < p / a)
      res = a <= h;
    else
      res = go(a % p, n, p, h);
    if (res)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
