Next Lucky Number

4.7

16 votes
Approved, Basic Programming, Implementation, Medium, Open, Recursion, Two dimensional
Problem

Lucky numbers are defined as the numbers consisting only of digits 3 and 5. So, given a number N, you have to print the least lucky number strictly greater than N.

Input:
First line of input contains number of test cases T. Each test case contains a single number N.

Output:
For each test case, print the next lucky number in a separate line.

Constraints:
1<=T<=1000
1<=N<=10100

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?