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:
import bisect
import collections
import functools
import itertools
import math
import heapq
import random
import string


def repeat(_func=None, *, times=1):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            for _ in range(times):
                func(*args, **kwargs)

        return wrapper

    if _func is None:
        return decorator
    else:
        return decorator(_func)


def unpack(func=int):
    return map(func, input().split())


def l_unpack(func=int):
    """list unpack"""
    return list(map(func, input().split()))


def s_unpack(func=int, rev=False):
    """sorted list unpack"""
    return sorted(map(func, input().split()), reverse=rev)


def ml_unpack(n):  # multiple line unpack
    """list of n integers passed on n line, one on each"""
    return [int(input()) for _ in range(n)]


def range_n():
    return range(int(input()))


def getint():
    return int(input())


def getmatrix(rows):
    return [list(map(int, input().split())) for _ in range(rows)]


def display_matrix(mat):
    for i in range(len(mat)):
        print(mat[i])


def factor(n):
    d = collections.defaultdict(int)
    while not n % 2:
        d[2] += 1
        n //= 2
    i = 3
    while i * i <= n:
        while not n % i:
            d[i] += 1
            n //= i
        i += 2
    if n > 1:
        d[n] += 1
    return d


@repeat(times=getint())
def main():
    n = getint()
    arr = list(range(1, 10))

    def util(idx, currsum, num):
        if idx == 9:
            if currsum == n:
                return num
            return float('inf')
        if currsum == n:
            return num
        if currsum > n:
            return float('inf')
        return min(
            util(idx + 1, currsum + arr[idx], num * 10 + arr[idx]),
            util(idx + 1, currsum, num)
        )

    ans = util(0, 0, 0)
    if ans == float('inf'):
        ans = -1
    print(ans)


main()