---
{"category_name":"easy","problem_code":"DIGITREM","problem_name":"Digit Removal","problemComponents":{"constraints":"- $1 \\leq T \\leq 10^5$\n- $1 \\leq N \\leq 10^9$\n- $0 \\leq D \\leq 9$\n","constraintsState":true,"subtasks":"- **Subtask 1 (100 points):** Original constraints","subtasksState":true,"inputFormat":"- The first line contains $T$ denoting the number of test cases. Then the test cases follow.\n- Each test case contains two integers $N$ and $D$ on a single line denoting the original number and the digit you need to avoid.\n","inputFormatState":true,"outputFormat":"For each test case, output on a single line the minimum non-negetive integer you should add to $N$.\n","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"5\n21 5\n8 8\n100 0\n5925 9\n434356 3\n","output":"0\n1\n11\n75\n5644\n","explanation":"**Test case $1$:** $N = 21$ does not contain the digit $D = 5$. Hence there is no need to add any integers to $N$. \n\n**Test case $2$:** If $1$ is added to $N = 8$, it becomes equal to $9$, which does not contain the digit $D = 8$.\n\n**Test case $3$:** The minimum integer you should add to $N = 100$ such that the final value of $N$ does not contain the digit $D = 0$ is $11$.\n\n**Test case $5$:** The minimum integer which is greater than $434356$ and does not contain the digit $D = 3$ is $440000$. So we should add $440000 - 434356 = 5644$.\n","isDeleted":false}}},"video_editorial_url":"https://youtu.be/SuPZa-Lmatk","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":1,"source_sizelimit":50000,"problem_author":"soumyadeep_21","problem_tester":"","date_added":"11-09-2021","tags":{"0":"math","1":"oct21","2":"soumyadeep_21"},"problem_difficulty_level":"Unavailable","best_tag":"","editorial_url":"https://discuss.codechef.com/problems/DIGITREM","time":{"view_start_date":1633944600,"submit_start_date":1633944600,"visible_start_date":1633944600,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=DIGITREM","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
### Read problem statements in [Bengali](https://www.codechef.com/download/translated/OCT21/bengali/DIGITREM.pdf), [Mandarin Chinese](https://www.codechef.com/download/translated/OCT21/mandarin/DIGITREM.pdf), [Russian](https://www.codechef.com/download/translated/OCT21/russian/DIGITREM.pdf), and [Vietnamese](https://www.codechef.com/download/translated/OCT21/vietnamese/DIGITREM.pdf) as well.
You are given an integer $N$ and a digit $D$. Find the minimum non-negetive integer you should add to $N$ such that the final value of $N$ does not contain the digit $D$.
<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>