Given two integer number **n** and** d.** The task is to find the number between **0** to **n** which contain the specific digit **d**.

**Input:**

The first line contains an integer **T, **the number of test cases. For each test case, there are two integer **n** & **d.**

**Output:**

For each test case, the output is the numbers that contain the integer d. Print "-1" if no such number found.

**Constraints:**

1 <= T <= 100

0 <= n <= 10^{3}

0 <= d <= 9

**Example:
Input**

2

20 5

50 2

5 15

2 12 20 21 22 23 24 25 26 27 28 29 32 42

**Explanation:**

**Testcase 1:**For number till 20, 5 appears in 5 itself and 15.

Author: Vanshika_pec

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

jhasaurabh312 | 138 |

Aaaaarohiiii | 136 |

Harsha_kunchala | 128 |

tushki | 124 |

RajaRajput | 117 |

ARUN_PUNDIR | 617 |

manishgupta8497 | 607 |

Abhimanyu_kumar | 559 |

KhyatiSoneji | 501 |

Aman___Jain | 496 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.