Video:
Read problem statements in Bengali, Mandarin Chinese, Russian, and Vietnamese as well.
You are given an integer and a digit . Find the minimum non-negetive integer you should add to such that the final value of does not contain the digit .
Input Format
- The first line contains denoting the number of test cases. Then the test cases follow.
- Each test case contains two integers and on a single line denoting the original number and the digit you need to avoid.
Output Format
For each test case, output on a single line the minimum non-negetive integer you should add to .
Constraints
Subtasks
- Subtask 1 (100 points): Original constraints
Sample Input 1
Sample Output 1
0
1
11
75
5644
Explanation
Test case : does not contain the digit . Hence there is no need to add any integers to .
Test case : If is added to , it becomes equal to , which does not contain the digit .
Test case : The minimum integer you should add to such that the final value of does not contain the digit is .
Test case : The minimum integer which is greater than and does not contain the digit is . So we should add .
0 Comments