#P1605. Unique Number

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).

输入格式

The first line contains a single positive integer t(1t50)t (1≤t≤50) — the number of test cases in the test. Then t test cases follow.

Each test case consists of a single integer number x(1x50)x (1≤x≤50).

输出格式

Output t 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.

样例

4 
1 
5 
15 
50 

1 
5 
69 
-1 

提示

来源:codeforces

by 20王聪 录入