A Lucky number is a number which has only the digits 4 and 7. Meesa makes a special function F(n) for a positive integer n that returns all good digits of number n from the left to the right. For example, the the output for number 147 is number 47. Meesa has two numbers :
Help Meesa to find the minimum number c (c > a) such that F(c) = b.
The first line contain T denoting the number of Test cases. Then T test cases follow . Each test case has only line contains two integers a and b. It is guaranteed that number b is lucky.
Print the number c in a new line that Meesa needs to find.
1 ≤ T ≤ 50
1 ≤ a, b ≤ 105
The minimum number x greater than 1 such that F(x) = 7 is 7 & so it is the answer.
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.