Problem B. Numeric Keypad
单点时限:1000ms
内存限制:256MB
The numberic keypad on your mobile phone looks like below:
By using the numeric keypad under above constrains, you can produce some
numbers like 177 or 480 while producing other numbers like 590 or 52 is
impossible.
Given a number K, find out the maximum number less than or equal to K that can
be produced.
The first line contains an integer T, the number of testcases.
For 50% of the data, 1 <= K <= 999.
For 100% of the data, 1 <= K <= 10500, t <= 20.
For each testcase output one line, the maximum number less than or equal to
the corresponding K that can be produced.
样例输出