CEQU - Crucial Equation


Let us see the following equation,

                                       ax + by = c

Given three positive integers a, b and c. You have to determine whether there exists at least one solution for some integers value of x and y where x, y may be negative or non-negative integers.

For example if a = 2, b = 4 and c = 8 then the equation will be 2x + 4y = 8, and hence, for x = 2 and y = 1, there exists a solution.

Let us see another example for a = 3, b = 6 and c = 7, so the equation will become 3x + 6y = 7 and there exists no solution satisfying this equation.

Input

Input starts with an integer T (1 ≤ T ≤ 105) denoting the number of test cases. Each test case contains three integers a, b, and c. (1 ≤ a, b, c ≤ 106).

Output

For each test case of input print the case number and “Yes” if there exists at least one solution, print “No” otherwise.

Example

Sample Input

Sample Output

2
2 4 8
3 6 7

Case 1: Yes
Case 2: No

Problem Setter: Md Abdul Alim, Dept. of Computer Science, Bangladesh University of Business & Technology


hide comments
Shashank Tiwari: 2015-07-13 09:54:50

https://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity

Rishabh Joshi: 2015-06-11 20:23:45

elementary. :)

Addy: 2015-05-31 22:06:36

Any hints please?

__hk__: 2015-05-31 14:37:10

@narendra pal: yes....as it is given x,y can be negative and "non-negative" integers , zero includes in 2nd category...

Narendra pal: 2015-05-31 11:53:19

can zero be the value of x or y ??

Naman Goyal: 2015-05-20 21:31:01

Good one, I went in completely wrong direction with prime factorizing a,b and c and wasted quite a lot time.

Bozidar: 2015-04-22 19:04:00

Don't forget to put space betwen ':' and 'Yes' or 'No' . Costed me a hell of nervs....

Dhruv k14: 2015-03-07 20:43:56

and the printing errors cause multiple WAs for the infiniteth time

Indian Cyber Army (IndiShell): 2015-02-03 17:57:46

My 30th :)
Feeling motivated !! :D

Gaurav sharma: 2015-01-30 18:49:20

go green...:P :) before this try ENIGMATH


Added by:Alim
Date:2014-10-15
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU
Resource:Own Problem