# MinAdd Codechef Solution

## MinAdd Codechef Solution

Answers will be Uploaded Shortly and it will be Notified on Telegram, SoÂ JOIN NOW

## Problem

Chef loves problems about digits and he came up with an interesting one.

Chef has given you two integersÂ ďż˝Â andÂ ďż˝. You should find theÂ minimumÂ non-negative integerÂ ďż˝, such thatÂ ďż˝+ďż˝Â hasÂ at mostÂ ďż˝Â distinct digits in its decimal representation.

For example,Â 1231Â has three distinct digits andÂ 100Â has two distinct digits.

### Input Format

• The first line of input will contain a single integerÂ ďż˝, denoting the number of test cases.
• The first and only line of each test case consists of two space-separated integersÂ ďż˝Â andÂ ďż˝, as described in the problem statement.

### Output Format

For each test case, output on a new line theÂ minimumÂ non-negative integerÂ ďż˝Â which satisfies the problem conditions.

### Constraints

• 1â‰¤ďż˝â‰¤105
• 1â‰¤ďż˝â‰¤109
• 1â‰¤ďż˝â‰¤10

### Sample 1:

Input

Output

9
30 1
56 4
364 2
125 3
37662730 3
41872528 4
73170084 8
90032975 1
7487471 3
3
0
2
0
603
1583
0
9967024
3

### Explanation:

Test caseÂ 1:Â 30Â hasÂ 2Â distinct digits which is more thanÂ 1, so we should addÂ 3Â toÂ 30Â to make it equal toÂ 33Â which has onlyÂ 1Â distinct digit.

Answers will be Uploaded Shortly and it will be Notified on Telegram, SoÂ JOIN NOW

## SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit HereÂ ScishowEngineerÂ Â  ThenÂ Follow US HEREÂ andÂ Join Telegram.

If You Want To Learn Something New Then Visit OurÂ Official Channel YOUTUBE