Prefix Digits
View as PDFSam is given two integers  and 
. In one operation, he is allowed to prepend a digit 
 
 to 
. As a servant of Sam, you are to determine if there exists a sequence of operations such that at the end 
 will be divisible by 
.
To ensure the integrity of your solution, there may be up to  test cases.
Constraints
Input Specification
The first line contains an integer , the number of test cases.
The first line of each test case contains  integers 
 and 
.
Output Specification
For each test case, output YES if a sequence of operations exists such that  will be divisible by 
, and 
NO otherwise.
Sample Input
1
6 4
Sample Output
YES
Explanation
For the first and only test case, with one operation, we can prepend  to 
 making it 
 which is divisible by 
.
Comments