Prefix Digits

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type

Sam is given two integers n and k. In one operation, he is allowed to prepend a digit d (0 \le d \le 9) to n. As a servant of Sam, you are to determine if there exists a sequence of operations such that at the end n will be divisible by k.

To ensure the integrity of your solution, there may be up to t test cases.

Constraints

1 \le t \le 10^5

1 \le n, k \le 10^9

Input Specification

The first line contains an integer t, the number of test cases.

The first line of each test case contains 2 integers n and k.

Output Specification

For each test case, output YES if a sequence of operations exists such that n will be divisible by k, 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 1 to 6 making it 16 which is divisible by 4.


Comments

There are no comments at the moment.