CF1462C.Unique Number

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

Unique Number

You are given a positive number xx. Find the smallest positive integer number that has the sum of digits equal to xx and all digits are distinct (unique).

Input

The first line contains a single positive integer tt (1t501 \le t \le 50) — the number of test cases in the test. Then tt test cases follow.

Each test case consists of a single integer number xx (1x501 \le x \le 50).

Output

Output tt answers to the test cases:

  • if a positive integer number with the sum of digits equal to xx and all digits are different exists, print the smallest such number;
  • otherwise print -1.

Samples

4
1
5
15
50
1
5
69
-1

在线编程 IDE

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