I am trying to become a good guy, because it doesn't take money to become good. So here's a short and simple problem statement because I am a good guy! 🙂
Given two integers and , find the minimum positive value of such that is divisible by .
is defined as the -times concatenation of the integer (without leading zeroes).
For example,
Input will start an integer () denoting the number of test cases.
In each test case, two space separated integers () and () will be given.
For each test case, print the minimum positive value of in a single separate line.
If no such exists, print -1.
Input | Output |
---|---|
2 123 9 123 10 | 3 -1 |
In the first test case, is divisible by 9 while 123123 and 123 are not divisible by 9. Thus 3 is the minimum possible value of for this test case. In the second test case, can never be divisible by 10 no matter what is. |