function M(n,t)
  for i,v in pairs(t) do
    if n == v then
      return true
    end
  end
  return false
end

T = io.read("*n")

A = {}
B = {}
C = {}
D = {}


for v = 1,T do
  table.insert(A, io.read("*n"))
  table.insert(B, io.read("*n"))
  table.insert(C, io.read("*n"))
  table.insert(D, io.read("*n"))
end

for v = 1,T do
  local j = A[v]
  local W = {}
  local ret = "No"

  while j >= 0 do
    if M(j, W) then
      ret = "Yes"
      break
    else
      table.insert(W, j)
    end

    if j >= B[v] then
      j = j - B[v]
    else
      break
    end

    if j <= C[v] then
      j = j + D[v]
    else
      break
    end
  end

  print(ret)
end