Vishwesh has won Rs. N on clearing GSoC. Now P of his friends are asking him for party. Vishwesh being a nice guy decides to spend the whole amount for party.
As he is a fair to his friends, he wants to give party of equal amount to all his friends. For this purpose he hacks into Google's server to change the value of N to make it exactly divisible by P. Now to reduce the risk of getting caught, he wants to know the minimum number of digits he has to change to make N divisible by P.
Vishwesh may change the value to 0 if required as 0 is divisble by all numbers.
INPUT CONSTRAINTS
INPUT FORMAT
First line of input contains a single integer T number of test cases. T lines follow each containing two space separated integers N and P.
OUTPUT FORMAT
Print answer of each test case in separate line
For 1st test case 10 is divisble by 5. So, 0 changes
For 2nd test case 1 change is required to make the number divisible.