Two water jugs

Given two jug capacities a and b, decide whether some sequence of fills, empties, and pours can leave exactly c liters in one jug.

Medium5MathNumber theorySimulationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

You have two jugs with capacities of aa and bb liters. Water is unlimited, and you may repeat the following three operations as many times as you like.

  • Fill one jug to the top.
  • Empty one jug completely.
  • Pour water from one jug into the other, stopping when the source jug is empty or the receiving jug is full.

Write a program that decides whether you can reach a state where one of the two jugs holds exactly cc liters.

Input

The first line contains the number of test cases TT. (1T100001 \le T \le 10000)

Each of the next TT lines contains one test case, given as three integers aa, bb, cc. (1a,b,c1091 \le a, b, c \le 10^9)

Output

For each test case, print YES on its own line if exactly cc liters can be measured, and NO otherwise.

Hint

For a=5a = 5, b=3b = 3, c=4c = 4, the following steps produce 4 liters.

  • Fill aa. (a=5a = 5, b=0b = 0)
  • Pour aa into bb. (a=2a = 2, b=3b = 3)
  • Empty bb, then pour aa into bb. (a=0a = 0, b=2b = 2)
  • Fill aa. (a=5a = 5, b=2b = 2)
  • Pour aa into bb. (a=4a = 4, b=3b = 3)