#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
int a, n, p, h, T;
void Exgcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  Exgcd(b, a % b, y, x);
  y -= a / b * x;
}
int Inv(int a) {
  int x, y;
  Exgcd(a, p, x, y);
  return (x % p + p) % p;
}
int Get(int a, int n, int p) {
  if (1LL * a * n < p) {
    return max(a, p - a * n);
  }
  return Get(p % a, (1LL * n * a + a + p % a) / p - 1, a);
}
bool Solve(void) {
  scanf("%d%d%d%d", &a, &n, &p, &h);
  a %= p;
  return (1LL * a * n < p ? a : Get(a, n, p)) <= h;
}
int main(void) {
  scanf("%d", &T);
  while (T--) {
    puts(Solve() ? "YES" : "NO");
  }
}
