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

Input

The first line contains a single positive integer 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 (1 ≤ x ≤ 50).

Output

Output t answers to the test cases:

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

Example

Input


4
1
5
15
50


Output


1
5
69
-1

Solution (in PYTHON3):

Solution:
test = int(input())
while test > 0:
    test -= 1
    n = int(input())
    rs = 1000000000
    for c1 in range(1, 10):
        if c1 > n:
            break
        if c1 == n:
            rs = min(rs, c1) 
            break
        s = c1
        for c2 in range(c1+1, 10):
            if c1 + c2 > n:
                break
            if c1 + c2 == n:
                rs = min(rs, s * 10 + c2)
                break
            s = s * 10 + c2
            for c3 in range(c2+1, 10):
                if c1 + c2 + c3 > n:
                    break
                if c1 + c2 + c3 == n:
                    rs = min(rs, s * 10 + c3)
                    break
                s = s * 10 + c3
                for c4 in range(c3+1, 10):
                    if c1 + c2 + c3 + c4 > n:
                        break
                    if c1 + c2 + c3 + c4 == n:
                        rs = min(rs, s * 10 + c4)
                        break
                    s = s * 10 + c4
                    for c5 in range(c4+1, 10):
                        if c1 + c2 + c3 + c4 + c5 > n:
                            break
                        if c1 + c2 + c3 + c4 + c5 == n:
                            rs = min(rs, s * 10 + c5)
                        s = s * 10 + c5
                        for c6 in range(c5+1, 10):
                            if c1 + c2 + c3 + c4 + c5 + c6 > n:
                                break
                            if c1 + c2 + c3 + c4 + c5 + c6 == n:
                                rs = min(rs, s * 10 + c6)
                            s = s * 10 + c6
                            for c7 in range(c6+1, 10):
                                if c1 + c2 + c3 + c4 + c5 + c6 + c7 > n:
                                    break 
                                if c1 + c2 + c3 + c4 + c5 + c6 + c7 == n:
                                    rs = min(rs, s * 10 + c7)
                                s = s * 10 + c7
                                for c8 in range(c7+1, 10):
                                    if c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 > n:
                                        break 
                                    if c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 == n:
                                        rs = min(rs, s * 10 + c8)
                                    s = s * 10 + c8
                                    for c9 in range(c8+1, 10):
                                        if c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 > n:
                                            break
                                        if c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 == n:
                                            rs = min(rs, s * 10 + c9)
                                        s = s * 10 + c9
                                        s = (s - c9) // 10
                                    s = (s - c8) // 10
                                s = (s - c7) // 10
                            s = (s - c6) // 10
                        s = (s - c5) // 10
                    s = (s - c4) // 10
                s = (s - c3) // 10
            s = (s - c2) // 10
        s = s - c1
    if rs == 1000000000:
        print(-1)
    else:
        print(rs)