756. The Leap Code

0

Medium

Martin's professor taught him about gray codes, hamming, and unit distances. He also introduced him to a similar concept called Leap codes.

A Leap code is a number in which all adjacent digits differ by 1. For example, 3456 and 9878 are Leap codes.

It is known that all single-digit numbers are Leap codes. Given a number N, find all the Leap codes that are less than or equal to N.

Input Format

The first line contains the number of test cases, T. Then T test cases follow. Each test case consists of a positive number N.

Output Format

For each test case, print all the Leap codes less than or equal to N in a new line.

Example

Input

1 50

Output

0 1 2 3 4 5 6 7 8 9 10 12 21 23 32 34 43 45

Constraints

1 <= T <= 100 1 <= N <= 109
Loading...

View Submissions

Console