open Scanf
open Printf

let consume c b x = if x <= c
  then x - b
  else if (x - c) mod b = 0
  then c
  else c + (x - c) mod b - b

let f a b c d = let memo = Hashtbl.create (min c 6400000) in
  let rec g x = if x < 0
    then printf "No\n"
    else if Hashtbl.mem memo x
    then printf "Yes\n"
    else (Hashtbl.add memo x (); g (consume c b (x+d)))
  in g (consume c b a)

let () = scanf "%d\n" (fun c ->
  for i = 1 to c do
    scanf "%d %d %d %d\n" f
  done)