CF1647A.Madoka and Math Dad

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Madoka and Math Dad

Madoka finally found the administrator password for her computer. Her father is a well-known popularizer of mathematics, so the password is the answer to the following problem.

Find the maximum decimal number without zeroes and with no equal digits in a row, such that the sum of its digits is nn.

Madoka is too tired of math to solve it herself, so help her to solve this problem!

Input

Each test contains multiple test cases. The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases. Description of the test cases follows.

The only line of each test case contains an integer nn (1n10001 \le n \le 1000) — the required sum of the digits.

Output

For each test case print the maximum number you can obtain.

Note

The only numbers with the sum of digits equal to 22 without zeros are 22 and 1111. But the last one has two ones in a row, so it's not valid. That's why the answer is 22.

The only numbers with the sum of digits equal to 33 without zeros are 111111, 1212, 2121, and 33. The first one has 22 ones in a row, so it's not valid. So the maximum valid number is 2121.

The only numbers with the sum of digits equals to 44 without zeros are 11111111, 211211, 121121, 112112, 1313, 3131, 2222, and 44. Numbers 11111111, 211211, 112112, 2222 aren't valid, because they have some identical digits in a row. So the maximum valid number is 121121.

Samples

5
1
2
3
4
5
1
2
21
121
212

在线编程 IDE

建议全屏模式获得最佳体验