Find the minimum number with the given sum of digits $$$s$$$ such that all digits in it are distinct (i.e. all digits are unique).For example, if $$$s=20$$$, then the answer is $$$389$$$. This is the minimum number in which all digits are different and the sum of the digits is $$$20$$$ ($$$3+8+9=20$$$).For the given $$$s$$$ print the required number.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 45$$$) — the number of test cases. Each test case is specified by a line that contains the only integer $$$s$$$ ($$$1 \le s \le 45$$$).

Print $$$t$$$ integers — the answers to the given test cases.

t = int(input())
for _ in range(t):
    n = int(input())
    count = 9
    lst = []
    if(n<10):
        print(n)
    else:
        while(n>=1):
           if(n-count>=0):
              n-=count
              lst.append(count)
           count-=1
        lst.sort()
        for i in range(len(lst)):
            lst[i] = str(lst[i])
        ans = "".join(lst)
        print(ans)

for _ in range(int(input())):
    n = int(input())
    s = ''
    for i in range(9, 0, -1):
        if n > i:
            s += str(i)
            n -= i
        else:
            s += str(n)
            break
    print(s[::-1])

t=int(input(""))
for i in range(t):
    s=int(input(""))
    c=9
    l=[]
    p=""
    while(s>0):
        if(c>s):
            c=s
            s=s-c
            l.append(c)
        else:
            s=s-c
            l.append(c)
            c=c-1
   # print(l)

    for i in range(len(l)):
        p=str(l[i])+p
    print(p)

t = int(input())

def solve():
    n = int(input())
    current_sol = set()

    def get(i, current_sum):
        if current_sum == 0:
            return True
        for i in range(9, 0, -1):
            if i not in current_sol and i <= current_sum:
                current_sol.add(i)
                found = get(i + 1, current_sum=current_sum-i)
                if found:
                    return True
                current_sol.remove(i)
    get(0, n)
    return ''.join(list(map(str, sorted(current_sol))))

res = []
for i in range(t):
    res.append(solve())

for i in res:
    print(i)

import sys
import collections
from math import ceil, gcd, sqrt, log
import bisect
# IMPORT PRACTICE AND CONCENTRATION

INF = float('inf')
mod = 1000000007

def solve():
    s = int(input())
    # A = list(map(int, input().split()))
    # s = input()
    # s2 = input()
    # net = 0

    ok = '123456789'
    minNum = 123456789

    for i in range(2 ** 9):
        b = bin(i)[2:]
        key = b.zfill(9)

        num = 0
        summ = 0

        for j in range(9):
            if key[j] == '1':
                summ += int(ok[j])
                num = num * 10 + int(ok[j])
                if summ >= s:
                    break
        if summ == s and num < minNum:
            minNum = num

    print(minNum)

t = int(input())

while t != 0:
    solve()

    t -= 1

import math

a=int(input())
b=[]
for i in range (0,a):
    b=int(input())
    answer=""
    for j in range (1,10):
        m=10-j
        if b>m:
            answer= str(m) + answer
            b-=m
        else:
            answer=str(b) +answer
            break
    print(answer)

class Solver1714C:

    def __init__(self):
        self.s = int(input())

    def solve(self):

        arr = []

        for i in range(9, 0, -1):
            if self.s >= i:
                self.s = self.s - i
                arr.append(i)

        arr = arr[::-1]

        print(''.join(map(str, arr)))

t = int(input())

while t:

    t -= 1

    cur = Solver1714C()

    cur.solve()

def solve():
    n=int(input())
    i=9
    s=0
    t=1
    s1=0
    while(s1!=n):
        if s1+i>n:
            i-=1
        else:
            s1+=i;
            s+=t*i;
            i-=1;
            t*=10;
    print(s)

t=int(input())
for i in range(t):
    solve()

for _ in range(int(input())):
    s = int(input())
    i = 9
    res = []
    while s!=0 and s>=i:
        res.append(str(i))
        s-=i
        i-=1
    if s>0:
        res.append(str(s))
    print(''.join(res[::-1]))

# varad
for _ in range(int(input())):
	n=int(input())
	ans=''
	for i in range(9,0,-1):
		if n>=i:
			n-=i
			ans=str(i)+ans
	print(ans)

for u in range(int(input())):
    n, a = int(input()), []
    cur = 9
    while n > cur:
        n -= cur
        a.append(cur)
        cur -= 1
    if n != 0: a.append(n)
    a.sort()
    print(*a, sep = "")

def check(n):
    if n > 39:
        i = 1456789
        step = 1000000
    elif n > 29:
        i = 6789
        step = 10000
    elif n > 19:
        i = 389
        step = 100
    elif n > 9:
        i = 19
        step = 10
    else:
        i = 1
        step = 1
    while True:
        s = []
        j = i
        while j > 0:
            if j % 10 in s:
                break
            else:
                s.append(j%10)
            j //= 10
        if sum(s) == n:
            return i
        else:
            i += step

n = int(input())
lst = [int(input()) for i in range(n)]
lst2 = []
for i in lst:
    lst2.append(check(i))
print(*lst2, sep='\n')

def fun(n):
    num = 0
    for i in range(9,0,-1):
        if n - i < 0:
            num += (n*(10**(9-i)))
            break
        else:
            n = n - i
            num += (i*(10**(9-i)))
    print(num)

t = int(input())

for _ in range(t):
    n = int(input())
    fun(n)

t=int(input())
for i in range(0,t):
    s=int(input())
    k=0
    no=0
    b=9
    while(s>9):

        no=no+(10**k)*b
        k=k+1
        s=s-b
        b=b-1
    if(s<=9 and s>=b):
        while(s<=9 and s>=b and s>0 ):

            no=no+(10**k)*(b)
            s=s-(b)
            b=b-1
            k=k+1
        if(s!=0):
            no=no+(10**k)*s

    else:
        no=no+(10**k)*s

    print(no)

from collections import Counter, deque, defaultdict
import math
from itertools import permutations, accumulate
from sys import *
from heapq import *
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from random import randint
xor = randint(10 ** 7, 10**8)
# https://docs.python.org/3/library/bisect.html
on = lambda mask, pos: (mask & (1 << pos)) > 0
lcm = lambda x, y: (x * y) // math.gcd(x,y)
rotate = lambda seq, k: seq[k:] + seq[:k] # O(n)
input = stdin.readline
'''
Check for typos before submit, Check if u can get hacked with Dict (use xor)
Observations/Notes:

'''
for _ in range(int(input())):
    n = int(input())
    ans = []
    seen = set()
    while True:
        if n == 0:
            break
        for i in range(9, 0, -1):
            if i <= n and i not in seen:
                ans.append(str(i))
                seen.add(i)
                n -= i
                break
    ans = ans[::-1]
    print(''.join(ans))

def solve():
    n=int(input())
    s=''
    for i in range(9,0,-1):
        if n>=i:
            s+=str(i)
            n-=i
    print(s[::-1])

t=int(input())
while(t):
   solve()
   t-=1

import sys

'''IF IT WORKS, IT WORKS. DON'T ASK ANYTHING FURTHER'''

# -------------------------- INPUT/OUTPUT ------------
def input_int():
    return int(sys.stdin.readline())

def input_str():
    return sys.stdin.readline().rstrip()

def input_int_arr():
    return list(map(int, sys.stdin.readline().split()))

def input_char_arr():
    return sys.stdin.readline().rstrip().split()

def print_ln(arg):
    sys.stdout.write(str(arg) + '\n')

def print_sp(arg):
    sys.stdout.write(str(arg) + ' ')

def print_only(arg):
    sys.stdout.write(str(arg))
# -----------------------------------------------------

def solve():
    ans= ''
    n = input_int()
    i = 9

    while n:
        if n-i <= 0:
            ans = str(n) + ans
            break
        else:
            ans = str(i) + ans
            n -= i
            i -= 1

    print_ln(ans)

def main():
    t = input_int()

    for _ in range(t):
        solve()

main()

def solve(case):
    s =  int(input())
    arr = []
    f = 0
    for i in range(9,0,-1):
        if f+i > s:
            continue
        f = f+i
        arr.append(i)
    for i in reversed(arr):
        print(i,end='')

    print("")

t = int(input())
for i in range(1,t+1):
    solve(i)

t = int(input())
for j in range(t):
    n = int(input())
    a = ""
    c = 9
    while n > c:
        n -= c
        a = str(c) + a
        c -= 1
    a = str(n) + a
    print(a)

test=int(input())
for _ in range(test):
    value=int(input())
    temp=[]
    ans=9
    while value>9 or value>ans:
        value-=ans
        temp.append(str(ans))
        ans-=1
    temp.append(str(value))
    temp.reverse()
    new=int("".join(temp))
    print(new)

t = int(input())
for i in range(0, t):
    n = int(input())
    g = n
    s = 9
    if n < 10:
        print(n)
        continue
    if n == 10:
        print(19)
        continue
    d = ""
    while n > s:
        if n > s:
            d += str(s)
            n-=s
            s-=1
        else:
            break
    sum1 = 0
    for j in range(0, len(d)):
        sum1 += int(d[j])
    if g - sum1 == 0:
        pass
    else:
        f = g - sum1
        d += str(f)
    counter = ""
    for j in range(len(d)-1, -1, -1):
       counter += d[j]
    print(int(counter))

import sys
input = sys.stdin.readline

for _ in range(int(input())):
    n = int(input())
    ans = []
    k = 9
    while n > 9:
        n = n - k
        ans.append(k)
        k -= 1

    if n in ans:
        k = ans[-1] - 1
        while n-k >= 0 and k >= 1:
            n = n - k
            ans.append(k)
            k -= 1
        if n > 0:
            ans.append(n)

    else:
        ans.append(n)
    print("".join([str(i) for i in ans[::-1]]))

t = int(input())
for i in range(t):
    s = int(input())
    a = []
    for i in range(9, 0, -1):
        if s // i > 0:
            s -= i
            a.append(i)

    print(*a[::-1], sep='')

# from cgi import test

#A
'''
test = int(input())
for i in range(test):
    n,H,M = map(int, input().split())
    arr = []
    for i in range(n):
        h,m = map(int,input().split())
        minute = h*60+m
        arr.append(minute)
    arr.sort()
    sleep = H*60+M
    i = 0
    while arr[i]<sleep and i < len(arr)-1:
        i+=1
    if arr[i] >=  sleep:
        time = (arr[i] - sleep)
    else:
        time = (24*60 - sleep + arr[0])
    h_out = time//60
    m_out = time%60
    print(h_out,m_out)
'''
#B
'''
test = int(input())
for i in range(test):
    n = int(input())
    arr = list(map(int, input().split()))
    i = n -1
    set1 = set()
    while arr[i] not in set1 and i>=0:
        set1.add(arr[i])
        i-=1
    print(i+1)
'''
#C
test = int(input())
for i in range(test):
    n = int(input())
    if n <= 9:
        print(n)
    else:
        k = 9
        sum = 0
        while sum < n and k >0:
            sum += k
            k-=1
        if sum > n:
            # print(k)
            count = 0
            out = ""
            j = k+2
            while j <=9:
                out = out + str(j)
                count+=j
                j+=1

            # print('count', count)
            out = str(n-count) + out
        else:
            j = k+1
            out = ""
            while j <=9:
                out = out + str(j)
                j+=1
        print(int(out))

import sys
input=sys.stdin.readline
for _ in range(int(input())):
    n=int(input())
    #n,h,m=map(int,input().split())
    #l=list(map(int,input().split()))
    s=""
    k=9
    while n>0:
        if k>n:
            s=str(n)+s
            n=0
        else:
            s=str(k)+s
            n=n-k
            k=k-1
    print(s)

for _ in range(int(input())):
    a=int(input())
    c=a
    s=''
    sum=0
    num=''
    b=[0,1,2,3,4,5,6,7,8,9]
    if a<10:
        print(a)
    else:

        while sum != a:
            if sum == a:
                print(a)
                break

            else:
                if c in b:
                    sum = sum + c
                    s=str(c)+s
                    print(int(s))
                    break
                else:
                    sum = sum + max(b)
                    s = str(max(b)) + s
                    c = c - max(b)
                    b.remove(max(b))

for _ in range(int(input())):
    v = int(input())
    s = ""
    n = 9
    while True:
        if v>n:
            s=str(n)+s
            v-=n
            n-=1
        else:
            break
    s=str(v)+s
    print(int(s))

for _ in range(int(input())):
    x=int(input())
    arr=[]
    k=9
    while x>k :
        arr.append(str(k))
        x-=k
        k=k-1

    arr.append(str(x))
    arr.reverse()
    print("".join(arr))

for _ in range(int(input())):
    n=int(input())
    cnt=0
    ans=""
    for i in range(9,-1,-1):
        if (cnt+i)>n:
            ans=ans+str(n-cnt)
            break
        else:
            cnt=cnt+i
            ans=ans+str(i)
    if ans[-1]=="0":
        print(ans[::-1][1::])
    else:
        print(ans[::-1])

t=int(input())
for efve in range(t):
    n=int(input())
    p=n
    k=9
    mas=[]
    while n-k>=0 and k>0:
        mas+=[k]
        n-=k
        k-=1
    n=p
    mas+=[n-sum(mas)]
    mas.reverse()
    if mas[0]==0:
        del mas[0]
    print(*mas, sep="")

for _ in range(int(input())):
    n = int(input())
    counted = ""
    maximum = 9
    i = n
    while n > 0:
        if n < 10:
            if str(i) not in counted:
                counted +=f"{i}"
                n -= i
                i = n
            else:
                i -= 1
        else:
            n = n - maximum
            counted +=f"{maximum}"
            maximum -= 1
            i = n
    print(counted[::-1])

def test():
    s = int(input())

    str_res = ''
    x = 9
    while s > 0:
        if s < x:
            x = s

        str_res += str(x)
        s -= x
        x -= 1

    str_res = str_res[::-1]
    print(str_res)

if __name__ == "__main__":
    count_test = int(input())
    for number_test in range(count_test):
        test()

n_testcases = int(input())

results = []

while (n_testcases > 0):

    max_usable = 9
    to_reach = int(input())

    num = []
    left = to_reach
    while left > 0 and max_usable > 0:
        #print("left: ", left)
        #print("max usable: ", max_usable)
        #print("actual building: ", num)
        #print("------------")
        while max_usable <= left and max_usable > 0:
            #print("########## left: ", left)
            #print("########## max usable: ", max_usable)
            #print("------------")
            num.append(str(max_usable))
            left -= max_usable
            max_usable -= 1
        max_usable -= 1

    num_int = int(''.join(num[::-1]))

    results.append(num_int)
    n_testcases -= 1

for i in range(len(results)):
    print(results[i])

#print("end")

from sys import stdin
input = stdin.buffer.readline

def func():
	rem = s
	ans = []

	for i in range(9, 0, -1):
		if i <= rem:
			rem -= i
			ans.append(str(i))

	print(''.join(sorted(ans)))

for _ in range(int(input())):
	s = int(input())
	func()

import sys

input = sys.stdin.readline

for _ in range(int(input())):
    n = int(input())
    ans = []
    for i in range(9, 0, -1):
        tmp = n - i
        if tmp < 0:
            ans.append(n)
            break
        else:
            n -= i
            ans.append(i)

    s = ''
    for i in ans[::-1]:
        s += str(i)
    print(int(s))

import sys

# -------------------------- INPUT/OUTPUT ------------

def input_int():
    return int(sys.stdin.readline())

def input_str():
    return sys.stdin.readline().rstrip()

def input_int_arr():
    return list(map(int, sys.stdin.readline().split()))

def input_char_arr():
    return sys.stdin.readline().rstrip().split()

def print_ln(num):
    sys.stdout.write(str(num) + '\n')

def print_sp(num):
    sys.stdout.write(str(num) + ' ')

def print_only(num):
    sys.stdout.write(str(num))
# -------------------------- INPUT/OUTPUT ------------

def solve():
    n = input_int()

    if n <= 9:
        print_ln(n)
    elif n <= 17:
        str1 = '9'
        print_ln(str(n-9) + str1)
    elif n <= 24:
        str1 = '89'
        print_ln(str(n-17) + str1)
    elif n <= 30:
        str1 = '789'
        print_ln(str(n-24) + str1)
    elif n <= 35:
        str1 = '6789'
        print_ln(str(n-30) + str1)
    elif n <= 39:
        str1 = '56789'
        print_ln(str(n-35) + str1)
    elif n <= 42:
        str1 = '456789'
        print_ln(str(n-39) + str1)
    elif n <= 44:
        str1 = '3456789'
        print_ln(str(n-42) + str1)
    else:
        print_ln('123456789')

def main():
    t = input_int()

    for _ in range(t):
        solve()

main()

for i in range(int(input())):
    n = int(input())
    arr=[]
    for i in range(1,10):
            if n>10-i:
                arr.append(10-i)
                n = n-10+i
            elif n>0:
                arr.append(n)
                break
    arr.reverse()
    for i in arr:
        print(i,end="")
    print()

from collections import *
from math import *
for y in range(int(input())):
    n=int(input())
#     lst=list(map(int,input().split()))
#     dic=defaultdict(int)
#     i=n-1
#     while i>=0:
#         if dic[lst[i]]==1:
#             break
#         i-=1
#         dic[lst[i]]=1
#     print(i+1)
    ans=''
    cur=9
    while n>0:
        if n<=cur:
            ans=str(n)+ans
            n=0
        else:
            ans=str(cur)+ans
            n-=cur
            cur-=1
    print(ans)

t = int(input())
for _ in range(t):
    n = int(input())
    ans = ''
    k = 9
    while (n>0):
        if n<k:
            ans = ans + str(n)
            break
        ans = ans + str(k)
        n-=k
        k -=1
    ans = ans[::-1]
    print(ans)

def solve():
    s = int(input())
    nums = []

    for i in range(9, 0, -1):
        if s - i >= 0:
            nums.append(str(i))
            s = s - i

    nums.sort()

    nums = ''.join(nums)

    print(int(nums))

t = int(input())

while t > 0:
    t -= 1
    solve()

# import io,os
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

import sys
from functools import lru_cache
from math import inf

sys.setrecursionlimit(10**5)

@lru_cache(10**5)
def dp(i,required_sum):
    if required_sum==0: return i
    return min((int(f"{i}{dp(j,required_sum-j)}") for j in range(i+1,10)),default=10**9)

def solve():
    s = int(input())
    ans = dp(0,s)
    print(ans)
T = int(input())
for _ in range(T):
    solve()

t = int(input())
for _ in range(t):
    n = int(input())
    s = ""
    idx = 9
    while n > idx:
        n -= idx
        s = str(idx) + s
        idx -= 1
    print(str(n) + s)

def finish(used: list):
    used.sort()
    print(*used, sep="")
for _ in range(int(input())):
    org = int(input())
    n = org
    if n < 10:
        print(n)
        continue
    used = []
    for i in range(9, -1, -1):
        used.append(i)
        n -= i
        if n == 0:
            finish(used)
            break
        if n < 0:
            used.pop()
            used.insert(0, org - sum(used))
            finish(used)
            break

for _ in range(int(input())):
    s = int(input())
    n = 9
    ans = ""
    while n:
        if s >= n:
            s -= n
            ans += str(n)
        n -= 1
    print(int(ans[::-1]))

n = int(input())
for i in range(n):
    a = int(input())
    k = []
    if a <= 9:
        k += [a]
    else:
        sum1 = 9
        k += [9]
        while sum(k) < a:
            for j in range(8, 1, -1):
                if a - sum(k) < j:
                    k += [a - sum(k)]
                    break
                else:
                    k += [j]
    ans = ''
    for elem in reversed(k):
        ans += str(elem)
    print(int(ans))

def dfs(pos,target,path):
        if target == 0:
            ans.append(int(path))
            return
        if target<0 or pos == len(nums):
            return

        for i in range(pos,len(nums)):
            dfs(i+1,target-nums[i],path+str(nums[i]))

t = int(input())

for _ in range(t):
    s = input()
    ans = []
    nums = [1,2,3,4,5,6,7,8,9]
    dfs(0,int(s),"")
    print(min(ans))

'''
Name: Minimum Varied Number
Link: https://codeforces.com/problemset/problem/1714/C
Categories:
'''
t = int(input())
slist = []
for i in range(t):
    slist.append(int(input()))

# esas cozum
final = []
for i in range(t):
    final.append([])
    for nz in range(9, 0, -1):  # senin metodu biraz degistirdim
        if slist[i] - nz >= 0:  # nz means 'nine to zero'
            final[i].append(nz)
            slist[i] -= nz

def Reverse(lst):
    new_lst = lst[::-1]
    return new_lst
# source for reversing list: https://www.geeksforgeeks.org/python-reversing-list/

for i in range(t):
    print(*Reverse(final[i]), sep="")

t = int(input())

def getNrFromList(vals):
	nr = 0
	for val in vals:
		nr = nr * 10 + val
	return nr

for _ in range(t):
	n = int(input())
	if n < 10:
		mini = n
	else:
		mini = float('inf')
		for i in range(1, 10):
			usedDigits = set([i])
			sumDigits = n - i
			notFound = False
			while sumDigits and not notFound:
				notFound = True
				for j in range(9, 0, -1):
					if j not in usedDigits and j <= sumDigits:
						sumDigits -= j
						usedDigits.add(j)
						notFound = False
						break
			if sumDigits == 0:
				mini = min(getNrFromList(sorted(list(usedDigits))), mini)
	print(mini)

t = int(input())

for _ in range(t):
    n = int(input())
    ans = ''
    i = 9
    while n != 0:
        if n >= i:
            n -= i
            ans = str(i) + ans
        else:
            ans = str(n) + ans
            n = 0
            break
        i -= 1
    print(ans)

t = int(input())
for _ in range(t):
    s = int(input())
    lis = [9,8,7,6,5,4,3,2,1]
    nn = ""
    while s > lis[0]:
        a = lis.pop(0)
        nn += str(a)
        s -= a
    if s != 0:
        nn += str(s)
    print(nn[::-1])

def fun(x):
    a=[i for i in range(1,10)]
    if x<10:
        return str(x)
    i=8
    ans=[]
    s=0
    while i<9:
        if s+a[i]<=x:
            s+=a[i]
            ans.append(str(a[i]))
        if s==x:
            return ans
        i-=1

for _ in range(int(input())):
    x=int(input())
    m=(fun(x))
    m="".join(m)
    print(m[::-1])

import sys
from sys import stdin
import math
import bisect
from collections import defaultdict,Counter,deque
from itertools import accumulate
from itertools import product,permutations,combinations,repeat,combinations_with_replacement
INF= 10**20
# binary search to find greater element less than key
def greatest_lesser(lst,num):
  i=0
  j=len(lst)-1
  ans=-1
  while i<=j:
    mid= (i+j)//2
    if num==lst[mid]:
      j=mid-1
    elif num<lst[mid]:
      j=mid-1
    else:
      ans=mid
      i=mid+1
  return ans
for _ in range(int(stdin.readline())):
    #n= int(stdin.readline())
    s= int(stdin.readline())
    sc=s
    if s<=9:
        print(s)
    else:
        ans=[]
        num=9
        while s>9 and num>0:
            s-=num
            ans.append(num)
            num-=1
        d= s
        #print(s,num)
        if d<=num:
            ans.append(d)
            print(''.join(map(str,reversed(ans))))
        else:
            ans.append(num)
            s-=num
            if num==d-num:
                ans.append(num-1)
                ans.append(1)
            else:
                num-=1
                if s<=num:
                    ans.append(s)
                else:
                    ans.append(num)
                    if num == s - num:
                        ans.append(num - 1)
                        ans.append(1)
                    else:
                        ans.append(s-num)
            print(''.join(map(str, reversed(ans))))

for t in range(int(input())):
    num = int(input())
    if num<=9:
        print(num)
    elif num<=17:
        Lst = [str(num-9),'9']
        print(''.join(Lst))
    elif num<=24:
        Lst = [str(num-17),'89']
        print(''.join(Lst))
    elif num<=30:
        Lst = [str(num-24),'789']
        print(''.join(Lst))
    elif num<=35:
        Lst = [str(num-30),'6789']
        print(''.join(Lst))
    elif num<=39:
        Lst = [str(num-35),'56789']
        print(''.join(Lst))
    elif num<=42:
        Lst = [str(num-39),'456789']
        print(''.join(Lst))
    elif num<=44:
        Lst = [str(num-42),'3456789']
        print(''.join(Lst))
    else:
        print('123456789')

t = int(input())
for i in (range (t)):
    numero = int(input())
    resultado = ""
    for i  in reversed(range(1,10)):
        if (numero>=i):
            numero= numero - i
            resultado = str(i) + resultado
    print(resultado)

# -*- coding: utf-8 -*-
"""
Created on Fri Aug 19 23:42:08 2022

@author: khale
"""

t = int(input())

for i in range(t):
    n = int(input())
    L = []
    x = 9
    while(n >= 10 or n > x):
        n = n - x
        L.append(x)
        x -= 1
    L.append(n)
    for i in range(len(L)-1,-1,-1):
        print(L[i],end='')
    print()

# from numpy import sort

def solve():
    s = int(input())
    a = []
    for i in range(9,  0, -1):
        if s >= i:
            s -= i
            a.append(i)
    a.reverse()
    for e in a:
        print(e, end="")
    print()

if __name__ == "__main__":
    T = int(input())
    for t in range(T):
        solve()

def get_str_res(s):
    str_res = str()
    x = 9
    while s > 0:
        x = min(s, x)
        str_res += str(x)

        s -= x
        x -= 1

    return str_res[::-1]

def test():
    s = int(input())
    str_res = get_str_res(s)
    print(str_res)

if __name__ == "__main__":
    count_test = int(input())
    for number_test in range(count_test):
        test()

import sys

def choose(curr_num) :
    if curr_num > 1 :
        if ans[curr_num-1] <= ans[curr_num-2] :
            return

    if sum(ans) == s:
        nums.append(ans[:])
        return

    for i in range(1, 10) :
        ans.append(i)
        choose(curr_num + 1)
        ans.pop()

    return

t = int(input())
for _ in range(t) :
    ans = []
    nums = []
    s = int(input())
    choose(0)
    min_len = sys.maxsize
    for elem in nums :
        min_len = min(min_len, len(elem))

    min_ans = []
    for elem in nums :
        if len(elem) == min_len :
            min_ans.append(elem)

    min_ans.sort()
    for elem in min_ans[0] :
        print(elem, end = "")
    print()

for _ in range(int(input())):
    s = int(input())
    n = d = 0
    for i in range(9, 0, -1):
        if d+i > s:
            n += (s-d)*10**(len(str(n)))
            break
        d += i
        n += i*10**(len(str(n)))
    print(n//10)

for _ in range(int(input())):
    x='';n=int(input())
    for i in range(9,0,-1):
        if n-i>=0:n-=i;x+=str(i)
    print(x[::-1])

t = int(input())

for i in range(t):
    n = int(input())
    p = 9
    a = 0
    k=1
    if (n>=10):
        while (n>=10):
            n=n-p
            a = p*k+a
            k=k*10
            p = p-1
        if (p>n):
            a=a+k*n
        else:
            while (n>0):
                if (p>n):
                    a=a+k*n
                    break
                n=n-p
                a = p*k+a
                k=k*10
                p = p-1
        print(a)

    else:
        print(n)

for _ in range(int(input())):
    n = int(input())
    #n,m = map(int, input().split())
    s = ""
    i = 0
    if n < 10:
        print(n)
        continue
    while n > 9:
        s = str(9 - i) + s
        n -= 9 - i
        i += 1
    if n != 0:
        while n >= int(s[0]):
            n -= int(s[0]) - 1
            s = str(int(s[0]) - 1) + s
        if n != 0 and len(s) < 9:
            s = str(n) + s
    print(int(s))

t = int(input())
for tidx in range(t):
    n = int(input())
    ans = 0
    req = n
    for i in range(9, 0, -1):
        ans += min(req, i) * 10**(9-i)
        req -= min(req, i)
        if req == 0: break
    print(ans)

import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
printf = lambda d: sys.stdout.write(str(d) + "\n")
def read_int(): return int(input())
def read_ints(): return list(map(int, input().split()))
def read_str(): return input().strip()

def dfs(n, s, mx):
    if n <= mx:
        return s + f"{n}"
    else:
        return dfs(n - mx, s + f'{mx}', mx - 1)

for _ in range(read_int()):
    n = read_int()
    print(dfs(n, '', 9)[::-1])

t=int(input())

def main(s):
    if s<=9 :
        return int(s)
    li=[9]
    counter=8
    while sum(li) < int (s):
        li=[counter]+li
        counter-=1
    li[0]=int(s) - sum(li[1:])

    ans=0
    for i in li:
        ans=ans*10 +i
    return(ans)

# print(main(10))

for i in range(t):
    s=int(input())
    print(main(s))

for Pythonic__Python in range(int(input())):
    n=int(input())
    l=[[i,True] for i in range(9,0,-1)]
    ans=""
    while n:
        for i in range(len(l)):
            if n>=l[i][0] and l[i][1]:
                l[i][1]=False
                n-=l[i][0]
                ans=str(l[i][0])+ans
    print(ans)

for _ in range(int(input())):
    x=int(input())
    arr=[]
    k=9
    while x>k :
        arr.append(str(k))
        x-=k
        k=k-1

    arr.append(str(x))
    arr.reverse()
    print("".join(arr))

t=int(input())
for efve in range(t):
    n=int(input())
    p=n
    k=9
    mas=[]
    while n-k>=0 and k>0:
        mas+=[k]
        n-=k
        k-=1
    n=p
    mas+=[n-sum(mas)]
    mas.reverse()
    if mas[0]==0:
        del mas[0]
    print(*mas, sep="")

t=int(input())
for _ in range(t):
    n=int(input())
    res=''
    for i in range(9,0,-1):
        if n>=i:
            res=str(i)+res
            n-=i
    print(res)

t = int(input())
for i in range(t):
    s = int(input())
    p = 9
    c = 0
    l=[]
    m = []
    if s<=9:
      l.append(s)
      l.reverse()
      print(*l)
    else:
        while(True):
            if s<=p:
              c=c+1

              l.append(s)
              l.reverse()
              for j in l:
              	u =str(j)
              	m.append(u)

              m = ''.join(m)
              print(m)
              break
            s=s-p
            c=c+1
            l.append(p)
            p=p-1

t = int(input())
for _ in range(t):
    s = int(input())
    if s < 10:
        print(s)
    else:
        sum = s - 9
        l = ["9"]
        i = 8
        while sum != 0:
            if i <= sum:
                sum -= i
                l.insert(0, str(i))
            i -= 1
        print("".join(l))

n=int(input())
for i in range(n):
    a=int(input())
    b=[0]*10
    c=''
    for j in range(9,0,-1):
        if b[j]==0 and a>=j:
            b[j]=1
            a-=j
            c=str(j)+c
    print(c)

t = int(input())
while(t>0):
    n=int(input())
    if(n<10):
        print(n)
    else:
        s = ""
        temp = 9
        while(temp>0 and n>0):
            if(n-temp>=0):
                s+=str(temp)
                n-=temp
            temp-=1
        print(s[::-1])
    t-=1

import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main(t):

    n = int(input())
    ans = ""
    for i in range(9,0,-1):
        if n >= i:
            ans += str(i)
            n -= i
        else:
            if n>0: ans += str(n)
            break

    ans = ans[::-1]

    print(ans)

T = int(input())
t = 1
while t<=T:
    main(t)
    t += 1

for _ in range(int(input())):
    n=int(input())
    ans=[]
    s=""
    for i in range(9,0,-1):
        if n-i==0:
            ans.append(i)

            break
        elif n>i:
            n-=i
            ans.append(i)

    for i in ans:
        s+=str(i)
    print(int(s[::-1]))

sum=0
s=[]
y=input()
for j in range(int(y)):
    x = input()
    f = int(x)
    for i in range(9,0,-1):
       if f>=i:
          sum=sum+i
          f=int(x)-sum
          s.append(i)
    s.reverse()
    for i in s:
       print(i,end='')
    print('\n')
    sum=0
    s=[]

N = int(input())

array = []

for s in range(N):
    n = 9
    value = 0
    count = 0
    s = int(input())
    while s >= 10:
        value = value + n * 10 ** count
        s -= n
        n -= 1
        count += 1
    while str(s) in str(value):
        value = value + n * 10 ** count
        s -= n
        n -= 1
        count += 1
    value = value + s * 10 ** count
    array.append(value)

for i in range(N):
    print(array[i])

for _ in range(int(input())):
    n = int(input())
    if n <= 9: print(n)
    else:
        k, s = 9, ''
        while True:
            if k <= n and n != 0:
                s += str(k)
                n -= k
                k -= 1
            elif n != 0 and k > n:
                s += str(n)
                break
            elif n == 0:
                break
        s = s[::-1]
        print(s)

for _ in range(int(input())):
	n = int(input())
	temp  = []

	for i in range(9,0,-1):
		temp.append(i)

	for i in range(1,len(temp)):
		temp[i] += temp[i-1]

# 	print(temp)

	out = [9,8,7,6,5,4,3,2,1]

# 	lol = 0

	for i in range(len(temp)):
		if n <= temp[i]:

			lol = i+1

			break

# 	print(lol)

	st1 = ''

	tempy = 0
	for i in range(lol-1):
		st1 += str(out[i])
		tempy += out[i]

	st1 += str(n - tempy)

	st1 = list(st1)

	st1.sort()

	outok = ''.join([str(elem) for elem in st1])

	print(outok)

	# print(st1)

for _ in range(int(input())):
    n = int(input())
    s = ''
    for i in range(9, 0, -1):
        if n > i:
            s += str(i)
            n -= i
        else:
            s += str(n)
            break
    print(s[::-1])

t = int(input())
for _ in range(t):
    s = int(input())
    a = ''
    n = 9

    while s > 0:
        if s < n:
            n = s
        a = str(n) + a
        s -= n
        n -= 1
    print(a)

t=int(input())
for h in range(0,t):
    ans=""
    i=0
    s=int(input())
    while s>9-i:
        ans=str(9-i)+ans
        s=s-(9-i)
        i=i+1
    ans=str(s)+ans
    print(ans)

import sys
import math

def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().strip().split()
def SI(): return sys.stdin.readline().strip()
def MIN_INT(): return -1 * sys.maxsize
def MAX_INT(): return sys.maxsize
def prefSum(arr, n):
    P = [0] * (n + 1)
    for k in range(1, n + 1):
        P[k] = P[k - 1] + arr[k - 1]
    return P

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

def solve():
    n = II()
    i = 1
    ans = [9]
    if n <= 9:
        print(n)
    else:
        now = sum(ans)
        x = True
        while now < n and x:
            while i < ans[-1]-1:
                if now + i == n:
                    ans.append(i)
                    x = False
                    break
                i += 1
            now += i
            ans.append(i)
            i = 1
    if sum(ans) == n:
        for i in ans[::-1]:
            print(i,end='')
        print()
    else:
        ans.pop(-1)
        for i in ans[::-1]:
            print(i,end='')
        print()

def main():
    t = II()
    for _ in range(t):
        solve()

main()

t=int(input())
for i in range(t):
    a=int(input())
    s=[]
    for j in range(9,0,-1):
        if j<=a:
            s.append(j)
            a=a-j
    print(s)

t=int(input())
for i in range(t):
  s=int(input())
  result=[]
  for j in range(9,0,-1):
    if(s>=j):
      result.append(j)
      s=s-j
  for k in result:
    print(k,end='')
  print()

for _ in range(int(input())):
    s = int(input())
    ans = ''
    for i in range(9, 0, -1):
        if i <= s:
            ans = str(i) + ans
            s -= i
        else:
            ans = str(s) + ans
            break
    print(ans)

for _ in range(int(input())):
    n = int(input())
    counted = ""
    maximum = 9
    i = n
    while n > 0:
        if n < 10:
            if str(i) not in counted:
                counted +=f"{i}"
                n -= i
            else:
                i -= 1
        else:
            n = n - maximum
            counted +=f"{maximum}"
            maximum -= 1
            i = n
    print(counted[::-1])

s=int(input())
lst=[]
for i in range(9,0,-1):
    s=s-i
    if(s>=0):
        lst.append(i)
    else:
        s=s+i
lst.reverse()
for i in lst:
    print(i,end="")

t=int(input())
for i in range(t):
	s=int(input())
	c=9
	m=0
	for k in range(45):
		if(s>0 and c>0):
			if(c<=s):
				m=m*10
				m+=c
				s-=c
				c-=1
	ch=str(m*10)
	ch = sorted(ch)
	ch = ''.join(ch)
	ch = int(ch)
	print(ch)

# https://codeforces.com/contest/1714/problem/C

for _ in range(int(input())):
    n = int(input())
    result = "9"

    for i in range(9, 0, -1):
        if n < int(result[0]):
            break
        result = str(i) + result
        n -= i

    print(str(n) + result[:-1])

n=int(input())
s=0
r=""
for i in range(9,0,-1):
    s+=i
    if s>n:
        s-=i
    else:
        r=str(i)+r
print(r)

t = int(input())
while(t>0):
    n=int(input())
    if(n<10):
        print(n)
    else:
        s = ""
        temp = 9
        while(temp>0 and n>0):
            if(n-temp>=0):
                s+=str(temp)
                n-=temp
            temp-=1
        print(s)
    t-=1

for _ in range(int(input())):
    n = int(input())
    if n <= 9:
        print(n)
        continue
    ans = ''
    for num in range(9, 0, -1):
        if n >= num:
            ans += str(num)
            n -= num
        else:
            ans += str(n)
            break
    print(ans[::-1])

cp = int(input())
for i in range(cp):
    n = int(input())
    r = ""
    for i in reversed(range(1, 10)):
        if n >= i:
            n -= i
            r = str(i)+r
            print(int(r))

sum=0
s=[]
y=input()
for j in range(int(y)):
    x = input()
    f = int(x)
    for i in range(9,0,-1):
       if f>=i:
          sum=sum+i
          f=int(x)-sum
          s.append(i)
    s.reverse()
    for i in s:
       print(i,end='')
    sum=0
    s=[]

for _ in range(int(input())):
    n = int(input())
    if n < 10:
        print(n)
        continue
    s = ""
    a = 9
    for a in range(9, 0, -1):
        if n >= a:
            s += str(a)
            n -= a
        else:
            s += str(n)
            break
    print(s[::-1])

for _ in range(int(input())):
    n = int(input())
    ans = []
    for num in range(9, 0, -1):
        if n >= num:
            ans.append(num)
            n -= num
        else:
            ans.append(n)
            break
    ans.sort()
    for i in ans:
        print(i, end='')

t=int(input())
while(t>0):
    n=int(input())
    result=""
    for i in range(9,0,-1):
        if(n>=i):
            result=str(i)+result
            n=n-i
    print(i)
    t-=1

a=[1000000000]
def solve(s,vis,arr,dp,l):
    if s<0:
        return
    elif s==0:
        a[0]=min(a[0],int("".join(arr)))
        return
    if dp[s][l]==1:
        return
    # if ans==1:
    #     return
    for i in range(1,10):
        if i not in vis:
            vis.append(i)
            arr.append(str(i))
            ans=solve(s-i,vis,arr,dp,l+1)
            vis.pop()
            arr.pop()
    dp[s][l]=1

t=int(input())
for i in range(t):
    s=int(input())
    # ans=0
    a[0]=1000000000
    dp=[[0 for i in range(10)] for j in range(s+5)]
    # print(solve(s))
    vis=[]
    arr=[]
    solve(s,vis,arr,dp,0)
    print(a[0])

t = int(input())

for i in range(t):
    x = int(input())
    s = ""
    mn = 9
    while True:
        if x <= 9:
            s += f'{x}'
            break
        else:
            s += f'{mn}'
            x -= mn
            mn -= 1
    print(int(s[::-1]))

t=int(input())
for _ in range(t):
    s=input()
    s=int(s)
    ans=[1,2,3,4,5,6,7,8,9]
    for i in range(9):

        if sum(ans)-s==0:
            print(*ans, sep='')
            break
        if sum(ans)-s>=ans[-1]:
            ans.pop()
        else:
            ans.pop(sum(ans)-s-1)

test=int(input())
while test:
    n=int(input())
    dig=-1
    s=0
    for i in range(9,0,-1):
        s+=i
        if s>n:
            dig=i+1
            s-=i
            break
    if dig==-1:
        dig=9
    ans=[]
    req=n-s
    if req==0:
        for j in range(dig,10):
            ans.append(j)
    else:
        ans.append(req)
        for j in range(dig,10):
            ans.append(j)
    ans.sort()
    for i in ans:
        print(i,end='')
    print()
    test-=1

import sys
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

############ Input code below ############

# Probem 1729B - Decode String

# t=inp()
# while t>0:
#     n=inp()
#     encoded=inp()
#     decoded=""
#     while encoded>0:
#         if encoded % 10 == 0:
#             lvalue = (encoded//10) % 100
#             encoded //= 1000
#         else:
#             lvalue = encoded % 10
#             encoded //= 10
#         lvalue += 96
#         decoded = chr(lvalue)+decoded
#     t-=1
#     print(decoded)

# Probem 1729A - Two Elevators

# t=inp()
# while t>0:
#     a,b,c = invr()
#     if (a < abs(b-c)+c):
#         print(1)
#     elif (a > abs(b-c)+c):
#         print(2)
#     else:
#         print(3)
#     t-=1

# Problem 1722B Colourblindness
# t = inp()
# while t>0:
#     n = inp()
#     a = [*input()]
#     b = [*input()]
#     in_a = set([i for i, x in enumerate(a) if x == "R"])
#     in_b = set([i for i, x in enumerate(b) if x == "R"])
#     if in_a == set() and in_b == set():
#         print("YES")
#     elif in_a == set() or in_b == set():
#         print("NO")
#     elif in_a ^ in_b == set():
#         print("YES")
#     else:
#         print("NO")
#     t-=1

# # Problem 1721A Image
# t = inp()
# while t>0:
#     a = set([*input().split()[0]])
#     b = set([*input().split()[0]])
#     c = a.union(b)
#     print(len(c)-1)
#     t-=1

# Problem 1722A Spell Check
# t = inp()
# while t>0:
#     n, a = inp(), input()
#     if n != 5:
#         print("NO")
#     elif "T" in a and "i" in a and "m" in a and "u" in a and "r" in a:
#         print("YES")
#     else:
#         print("NO")
#     t-=1

# # Problem 1716A 2-3 Moves
# t =inp()
# while t>0:
#     n = abs(inp())
#     if n==1: print(2)
#     elif n%3==0:
#         print(n//3)
#     else: print(n//3+1)
#     t-=1

# # Problem 1715A Crossmarket
# t =inp()
# while t>0:
#     n,m = inlt()
#     if n==1 and m == 1: print(0)
#     elif n==1: print(m)
#     elif m==1: print(n)
#     else: print(min(n,m)*2+max(n,m)-2)
#     t-=1

# Problem 1714C Minimum Varied Number
t =inp()
while t>0:
    s = inp()
    ans=""
    i = 9
    while s>0 and s>=i:
        ans = str(i)+ans
        s-=i
        i-=1
    ans = str(s)+ans
    print(ans)
    t-=1

def deco(num):
	arr = []
	count = 9
	if num < 10:
		return num
	while num >= 10 or num in arr:
		num = num - count
		arr.append(count)
		count = count - 1
	if num > 0:
		arr.append(num)

	arr.sort()
	#print(arr)
	return int(''.join(map(str,arr)))

n = int(input())
while n  != 0:
	s = int(input())
	deco(s)
	n -=1

from sys import stdin, stdout
import math

def main():

    tests = int(stdin.readline())

    # arr = [int(x) for x in stdin.readline().split()]

    def MVN(num):
        res = 0
        temp = 10
        place = 0
        while num > temp:
            res += (temp - 1)*(pow(10,place))
            num -= (temp - 1)
            temp -= 1
            place += 1
        res += (num)*(pow(10,place))
        return res

    for i in range(tests):
        num = int(stdin.readline())
        # for alarm in range(alarms):
        #     [H2, M2] = [int(x) for x in stdin.readline().split()]
        #     sleep = min(sleep, ELTS(H1,M1,H2,M2))
        stdout.write("\n")

if __name__ == "__main__":
    main()

t = int(input())
for tidx in range(t):
    n = int(input())
    ans = 0
    req = n
    for i in range(9, 0, -1):
        ans += min(req, i) * 10**(9-i)
        req -= i
    print(ans)

t=int(input())
while(t>0):
    n=int(input())
    result=''
    for i in range(9,0,-1):
        if(n>=i):
            result=str(i)+result
            n=n-i
    print(i)
    t-=1

t = int(input())
while t > 0:
    n = int(input())
    x = 9
    s = ''
    s1 = 0
    while n - s1 >= 10:
        s1 += x
        s += str(x)
        x -= 1
    ok = 0
    for i in range(x,0,-1):
        sm = 0
        if ok == 1:
            break
        s2 = ''
        for j in range(i,0,-1):
            sm += j
            s2 += str(j)
            if n - s1 - sm == 0:
                ok = 1
                break
    print((s + s2)[::-1])
    m = ''
    t -= 1

t = int(input())

for i in range(t):
    n = int(input())
    p = 9
    a = 0
    k=1
    if (n>=10):
        while (n>=10):
            n=n-p
            a = p*k+a
            k=k*10
            p = p-1
        if (p>n):
            a=a+k*n
        else:
            while (n>0):
                n=n-p
                a = p*k+a
                k=k*10
                p = p-1
        print(a)

    else:
        print(n)

from collections import Counter
#from collections import defaultdict
# values=Counter(tasks).values()
# for i,n in l1:
# import math
# from collections import Counter
# l=defaultdict(list)
import sys
import math
# import bisect
# from numpy import delete
# import itertools
# from datetime import datetime
for _ in range(int(sys.stdin.readline())):
    n=int(sys.stdin.readline())
    # n,h,m=map(int,sys.stdin.readline().split())
    # a=[int(i) for i in sys.stdin.readline().split()]
    #s=input()
    print((n % 9 + 1) * pow(10, (n // 9)) - 1)

t = int(input())

for _ in range(t):
    n = int(input())
    ans = ''
    i = 9
    while n != 0:
        if n >= i:
            n -= i
            ans = str(i) + ans
        else:
            ans = str(i) + ans
            n -= i
            break
        i -= 1
    print(ans)

for _ in range(int(input())):
    s = int(input())
    if s >= 9:
        num = 9
        cou = ['9']
        for i in range(9)[::-1]:
            temp = s-num
            if temp <= i:
                cou.append(str(temp))
                cou = cou[::-1]
                print("".join(cou))
                break
            else:
                num += i
                cou.append(str(i))
    else:
        print(s)

def fun(n):
    num = 0
    for i in range(9,0,-1):
        if n - i < 0:
            num += (n*(10**(9-i)))
            break
        else:
            n = n - i
            num += (i*(10**(9-i)))
    print(num)

t = int(input())

def solve():
    n = int(input())
    current_sol = set()

    def get(i, current_sum):
        if current_sum == 0:
            return True
        for i in range(1, 10):
            if i not in current_sol and i <= current_sum:
                current_sol.add(i)
                found = get(i + 1, current_sum=current_sum-i)
                if found:
                    return True
                current_sol.remove(i)
    get(0, n)
    return list(sorted(current_sol))

res = []
for i in range(t):
    res.append(solve())

for i in res:
    print(i)

t=int(input())
while(t>0):
    n=int(input())
    result=""
    for i in range(9,0,-1):
        if(n>=i):
            result+=str(i)
    print(i)
    t-=1

for _ in range(int(input())):
    n = int(input())
    ans = ''
    for num in range(9, 0, -1):
        if n >= num:
            ans += str(num)
            n -= num
        else:
            ans += str(n)
            break
    print(ans[::-1])

import sys

input = sys.stdin.readline

for _ in range(int(input())):
    n = int(input())
    ans = []
    for i in range(9, 0, -1):
        tmp = n - i
        if tmp < 0:
            ans.append(n)
            break
        else:
            n -= i
            ans.append(i)

    for i in ans[::-1]:
        print(i, end='')
    print()

from collections import deque

t = int(input())

for _ in range(t):
    s = int(input())

    d = deque()
    for n in reversed(range(1, 10)):
        if s >= n:
            d.appendleft(n)
            s -= n
        else:
            d.appendleft(s)
            break

    print(*list(d), sep = '')

n = int(input())

for z in range(n):
    a = int(input())

    number_list = []
    if a < 10:
        print(8)
        continue

    x = 0

    while a != sum(number_list):
        if sum(number_list) < a:
            difference = a - sum(number_list)
            if difference < (9 - x):
                number_list.insert(0, difference)
            else:
                number_list.insert(0, 9 - x)
                x += 1
    print("".join(list(map(str, number_list))))

def solve():
    n=int(input())
    s=''
    for i in range(9,0,-1):
        if n>=i:
            s+=str(i)
            n-=i
    print(s)

t=int(input())
while(t):
   solve()
   t-=1

for _ in range(int(input())):
    n = int(input())
    ans = []
    for num in range(9, 0, -1):
        if n >= num:
            ans.append(num)
            n -= num
        else:
            ans.append(n)
            break
    ans.sort()
    for i in ans:
        print(i, end='')
    print()

# -*- coding: utf-8 -*-
"""
Created on Fri Aug 19 23:42:08 2022

@author: khale
"""

t = int(input())

for i in range(t):
    n = int(input())
    if(n==45):
        print(123456789)
        continue
    if(n==10):
        print(19)
    L = []
    x = 9
    while(n >= 10):
        n = n - x
        L.append(x)
        x -= 1
    L.append(n)
    for i in range(len(L)-1,-1,-1):
        print(L[i],end='')
    print()

# A

def inpA():
    t = int(input())
    ans = []
    for i in range(t):
        ans_min = 23 * 60 + 59
        n, H, M = map(int, input().split())
        go_sl = H * 60 + M
        for j in range(n):
            h, m = map(int, input().split())
            awake = h * 60 + m
            if go_sl <= awake:
                ans_min = min(ans_min, awake - go_sl)
            else:
                ans_min = min(ans_min, 24 * 60 + awake - go_sl)
        ans.append([ans_min // 60, ans_min % 60])

    for i in ans:
        print(i[0], i[1])

def inpB():
    t = int(input())
    ans = []
    for i in range(t):
        hesh = [-1,] * int(1e7)
        ans_max = -1
        n = input()
        seq = map(int, input().split())
        for j, v in enumerate(seq):
            if hesh[v] != -1:
                ans_max = hesh[v]
                hesh[v] = j
            else:
                hesh[v] = j
        ans.append(ans_max + 1)

    for i in ans:
        print(i)

def inpC():
    t = int(input())
    ans = []
    for i in range(t):
        v = list(reversed([1, 2, 3, 4, 5, 6, 7, 8, 9]))
        s = int(input())
        tans = []
        j = 0
        while s != 0:
            if v[j] <= s:
                tans.append(str(v[j]))
                s -= v[j]
                v.pop(j)
            else:
                j += 1
        ans.append(''.join(tans))

    for i in ans:
        print(i)

inpC()

for s in[*map(int,open(0))][1:]:
    r='';i=9
while s:
    if i<=s:s-=i;r=str(i)+r
    i-=1
    print(r)

for _ in range(int(input())):
    n=int(input())
    cnt=0
    ans=""
    for i in range(9,-1,-1):
        if (cnt+i)>n:
            ans=ans+str(n-cnt)
            break
        else:
            cnt=cnt+i
            ans=ans+str(i)
    print(ans)

from sys import stdin
input = stdin.buffer.readline

def func():
	rem = s
	ans = ''

	for i in range(9, 0, -1):
		if i <= rem:
			rem -= i
			ans += str(i)

	print(ans)

for _ in range(int(input())):
	s = int(input())
	func()

test=int(input())
for _ in range(test):
    value=int(input())
    temp=[]
    ans=9
    while value>9 and value>ans:
        value-=ans
        temp.append(str(ans))
        ans-=1
    temp.append(str(value))
    temp.reverse()
    new=int("".join(temp))
    print(new)

t=input()
res=''
nums=[i for i in range(1,10)]
while int(t)>nums[-1]:
    t=int(t)-nums[-1]
    res+=str(nums.pop())
res+=str(t)
print(int(res[::-1]))

def solve():
    n=int(input())
    print('1'*n)

t=int(input())
while(t):
   solve()
   t-=1

from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

####################################---fast-input-output----#########################################

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = read(self._fd, max(fstat(self._fd).st_size, 8192))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = read(self._fd, max(fstat(self._fd).st_size, 8192))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

stdin, stdout = IOWrapper(stdin), IOWrapper(stdout)
graph, mod, szzz =  {}, 10**9 + 7, lambda: sorted(zzz())
def getStr(): return input()
def getInt(): return int(input())
def listStr(): return list(input())
def getStrs(): return input().split()
def isInt(s): return '0' <= s[0] <= '9'
def input(): return stdin.readline().strip()
def zzz(): return [int(i) for i in input().split()]
def output(answer, end='\n'): stdout.write(str(answer) + end)
def lcd(xnum1, xnum2): return (xnum1 * xnum2 // gcd(xnum1, xnum2))

dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

#################################################---Some Rule For Me To Follow---#################################
"""
    --instants of Reading problem continuously try to understand them.

    --If you Know some-one , Then you probably don't know him !

    --Try & again try, maybe you're just one statement away!

"""
##################################################---START-CODING---###############################################

def solve(s):
    sz = 0;
    i=0;
    loop = 1
    while True:
        sz+=9-i
        if(sz>s):
            break
        if(sz==s):
            loop+=1;
            break
        i+=1;
        loop +=1
    lst = []
    for i in range(loop):
        lst.append(9-i)
    lst = lst[::-1]
    ans = 10<<11;

    while (sum(lst)!=s):
        lst[0]-=1
    print(''.join(str(i) for i in lst))

for _ in range(getInt()):
    s = getInt()
    solve(s)

for _ in range(int(input())):
    n = int(input())
    if n <= 9:
        print(n)
        continue
    ans = ''
    for num in range(9, 0, -1):
        if n >= num:
            ans += str(num)
            n -= num
        else:
            ans += str(n)
            break
    print(ans[::-1])

import sys

# -------------------------- INPUT/OUTPUT ------------

def input_int():
    return int(sys.stdin.readline())

def input_str():
    return sys.stdin.readline().rstrip()

def input_int_arr():
    return list(map(int, sys.stdin.readline().split()))

def input_char_arr():
    return sys.stdin.readline().rstrip().split()

def print_ln(num):
    sys.stdout.write(str(num) + '\n')

def print_sp(num):
    sys.stdout.write(str(num) + ' ')

def print_only(num):
    sys.stdout.write(str(num))
# -------------------------- INPUT/OUTPUT ------------

def solve():
    n = input_int()

    if n <= 9:
        print_ln(n)
    elif n <= 17:
        str1 = '9'
        print_ln(str(n-9) + str1)
    elif n <= 24:
        str1 = '89'
        print_ln(str(n-17) + str1)
    elif n <= 30:
        str1 = '789'
        print_ln(str(n-24) + str1)
    elif n <= 35:
        str1 = '6789'
        print_ln(str(n-30) + str1)
    elif n <= 39:
        str1 = '56789'
        print_ln(str(n-35) + str1)
    elif n <= 42:
        str1 = '56789'
        print_ln(str(n-39) + str1)
    elif n <= 44:
        str1 = '456789'
        print_ln(str(n-42) + str1)
    else:
        print_ln('123456789')

def main():
    t = input_int()

    for _ in range(t):
        solve()

main()

for i in range(int(input())):
    n = int(input())
    if n > 9:
        i=9
        s='9'
        while(n-i > 0):
            n = n - i
            i = i - 1
            s = s + str(i)
        string = str(n) + s[1:]
        print(int(string[::-1]))
    else:
        print(n)

for i in range(int(input())):
    s = int(input())
    ans = 0
    arr=[]
    if s<9:
        for i in range(s,0,-1):
            if (ans+i)<=s:
                ans=ans+i
                arr.append(i)
    else:
        for i in range(9,0,-1):
            if (ans+i)<=s:
                ans=ans+i
                arr.append(i)

    print(arr)

def deco(num):
	arr = []
	count = 9
	if num < 10:
		return num
	while num >= 10 or num in arr:
		num = num - count
		arr.append(count)
		count = count - 1
	if num > 0:
		arr.append(num)

	arr.sort()
	print(arr)
	return int(''.join(map(str,arr)))

t=int(input())
while(t>0):
    n=int(input())
    result=""
    for i in range(9,0,-1):
        if(n>=i):
            result+=str(i)
    print(i)
    t-=1

t = int(input())

limits = [
    sum(range(i, 10)) for i in range(1, 10)
][::-1]

print(limits)

def process(s):
    l = None
    for i, limit in enumerate(limits):
        if s <= limit:
            l = i + 1
            break
    s2 = limits[l - 1]
    nums = list(range(10 - l, 10))
    if s == s2:
        return nums
    #print(s2, nums)
    for i in range(len(nums)):
        while nums[i] > i + 1:
            if s2 == s:
                return nums
            nums[i] -= 1
            s2 -= 1
    return []

for i in range(t):
    s = int(input())
    print(*process(s), sep='')

import sys

input = sys.stdin.readline

for _ in range(int(input())):
    n = int(input())
    ans = []
    for i in range(9, 0, -1):
        tmp = n - i
        if tmp < 0:
            ans.append(n)
            break
        else:
            n -= i
            ans.append(i)

    for i in ans[::-1]:
        print(i, end='')
    print()

t=int(input())
for i in range(t):
    s=int(input())
    if s<10:
        print(s)
    else:
        m=s
        st=''
        j=9
        while j>0:
            if m>9:
                st+=str(j)
                m-=j
            j-=1
        st1= str(m) + st[::-1]
        print(st1)

for _ in range(int(input())):
    s = int(input())
    if s >= 9:
        num = 9
        cou = ['9']
        for i in range(9)[::-1]:
            temp = s-num
            if temp < i+1:
                cou.append(str(temp))
                cou = cou[::-1]
                print("".join(cou))
                break
            else:
                num += i
                cou.append(str(i))
    else:
        print(s)

n_testcases = int(input())

results = []

while (n_testcases > 0):

    max_usable = 9
    to_reach = int(input())

    num = []
    left = to_reach
    while left > 0 and max_usable > 0:
        #print("left: ", left)
        #print("max usable: ", max_usable)
        #print("actual building: ", num)
        #print("------------")
        while max_usable <= left and max_usable > 0:
            #print("########## left: ", left)
            #print("########## max usable: ", max_usable)
            #print("------------")
            num.append(str(max_usable))
            left -= max_usable
            max_usable -= 1
        max_usable -= 1

    num_int = int(''.join(num[::-1]))

    results.append(num_int)
    n_testcases -= 1

for i in range(len(results)):
    print(results[i])

print("end")

import sys
import math
import copy

t = int(input())
for tst in range(t):
    s = int(input())
    ans = []
    for e in [9, 8, 7, 6, 5, 4, 3, 2, 1]:
        if s-sum(ans)-e >= 0:
            ans.insert(0, e)
            print(ans)
    res = ""
    for n in ans:
        res += str(n)
    print(res)

for s in[*map(int,open(0))][1:]:
    r='';i=9
while s:
    if i<=s:s-=i;r=str(i)+r
    i-=1
    print(r)

t = int(input())
for _ in range(t):
    n = int(input())
    s = ""
    for i in range(9, 0, -1):
        if n >= i:
            s = str(i) + s
            n -= i
        else:
            s = str(n) + s
            break
    print(s)

N = int(input())
for a in range(N):
 i = [9,8,7,6,5,4,3,2,1]
 x = []
 n = int(input())
 for k in range(9):
  if(n>9):
    x.append(i[0])
    n = n-i[0]
    i.remove(i[0])

  else:
    x.append(n)
    break

 x.reverse()

 for x1 in x:
    print(x1,end='')
 print()

n = int(input())
while n>0:
    n-=1
    m = ""
    a = int(input())
    b = ""
    if a>=10:
        for i in range(9,0,-1):
            if a ==0:
                b=b
            elif a>=i:
                a-=i
                b+=str(i)
            elif a==i:
                b+=str(i)
            else:
                b+=str(a)
                print(b)
                break
        for j in range(1,len(b)+1,1):
            m += b[-j]
        print(m)
    else:
        print(a)

# https://codeforces.com/contest/1714/problem/C

for _ in range(int(input())):
    n = int(input())
    result = "9"

    for i in range(9, 0, -1):
        if n < int(result[0]):
            break
        result = str(i) + result
        n -= i

    print(str(n) + result[:-1])

def get_integers_down(number_of_integers):
    string = ""
    sum = 0
    for b in range (9, 9-number_of_integers, -1):
        string = str(b) + string
        sum = b + sum
    return [string, sum]
def inverse_sums(num):
    return sum([9-n for n in range(num)])
countdown = [inverse_sums(num) for num in range(10)]
t = int(input())
for a in range(t):
    n = int(input())
    if(n<9):
        print(n)
        continue
    else:
        for each in countdown:
            if n == each:
                print(get_integers_down(countdown.index(each))[0])
                break
            if n<each:
                sum_up = countdown.index(each) - 1
                break
    add_on_string = get_integers_down(sum_up)[0]
    print(str(n - get_integers_down(sum_up)[1]) + add_on_string)

def solve():
    n=int(input())
    print('1'*n)

t=int(input())
while(t):
   solve()
   t-=1

for i in range(int(input())):

    def getSum(n):

        sum1 = 0;
        while (n != 0):
            sum1 = sum1 + n % 10;
            n = n // 10;

        return sum1;

    def smallestNumber(N):

        i = 1;
        while (1):

            if (getSum(i) == N):
                print(i);
                break;

            i += 1;

    N = int(input())
    (smallestNumber(N))

from collections import Counter
def smallestNum(s):
    if s < 10:
        return s
    prev = 10
    res = ''
    while s:
        if s < 10:
            res = str(s) + res
            return res
        prev -= 1
        s -= prev
        res = str(prev)+res

    return res

t = int(input())
while t:
    n = int(input())
    print(smallestNum(n))
    t -= 1

t = int(input())

for i in range(t):
    x = int(input())
    s = ""
    mn = 9
    while True:
        if x <= 9:
            s += f'{x}'
            break
        else:
            s += f'{mn}'
            x -= mn
            mn -= 1
    print(int(s))

# -*- coding: utf-8 -*-
"""
Created on Fri Aug 19 23:42:08 2022

@author: khale
"""

t = int(input())

for i in range(t):
    n = int(input())
    if(n==45):
        print(123456789)
    L = []
    x = 9
    while(n >= 10):
        n = n - x
        L.append(x)
        x -= 1
    L.append(n)
    for i in range(len(L)-1,-1,-1):
        print(L[i],end='')
    print()

t = int(input())
while t > 0:
    s = int(input())
    count = 9
    ret = ""
    while s > 0:
        if s > 10:
            s = s - count
            ret = str(count) + ret
            count -= 1
        elif s < 10 and str(s) not in ret:
            #print(s)
            ret = str(s) + ret
            s = 0
        else:

            ret = str(count) + ret
            s = s - count
            count -= 1
    t -= 1

for _ in range(int(input())):
    s = int(input())
    ans = ''
    for i in range(9, 0, -1):
        if i <= s:
            ans = str(i) + ans
            s -= i
        else:
            ans = str(s) + ans
            break
    print(ans)

# cook your dish here
for i in range(int(input())):
    # n,H,M=map(int,input().split())

    # w=[]
    # c=[23,59]
    # for k in range(n):
    #     h,m=map(int,input().split())
    #     a=[h,m]

    #     if H<=a[0]:
    #         if a[1]>=M:
    #             w.append([a[0]-H,a[1]-M])
    #         else:
    #             w.append([a[0]-H-1,60+a[1]-M])
    #     else:

    #         c=60-M
    #         p=23-H
    #         w.append([a[0]+p,c+a[1]])
    # w.sort()
    # print(*w[0])

    s=int(input())
    w=''
    e=int(s)
    for k in [1,2,3,4,5,6,7,8,9]:
        if s==0:
            break
        else:
            if s>=k:

                w+=str(k)
                s-=k
    q=''
    for k in [9,8,7,6,5,4,3,2,1]:
        if e==0:
            break
        else:
            if e>=k:

                q+=str(k)
                e-=k
    print(min(int(q),int(w),int(w[::-1]),int(q[::-1])))

import sys
input = sys.stdin.readline

for _ in range(int(input())):
    n = int(input())
    ans = []
    k = 9
    while n > 9:
        n = n - k
        ans.append(k)
        k -= 1
    if n in ans:
        k = ans[-1] - 1
        while k > 0:
            n = n - k
            ans.append(k)
            k -= 1
    else:
        ans.append(n)
    print("".join([str(i) for i in ans[::-1]]))

movimientos = int(input())
resultado = ""
for i in range(movimientos):
    numero = int(input())
    for j in reversed(range(1, 10)):
        if numero >= j:
            numero -= j
            resultado = str(j) + resultado
print(resultado)

n=int(input())
for j in range(n):
    s=int(input())
    lst=[]
    for i in range(9,0,-1):
        s=s-i
        if(s>=0):
            lst.append(i)
        else:
            s=s+i
    lst.reverse()
    for i in lst:

        print(i,end="")

t=input()
res=''
nums=[i for i in range(1,10)]
while int(t)>nums[-1]:
    t=int(t)-nums[-1]
    res+=str(nums.pop())
res+=str(t)
print(int(res[::-1]))

import sys
import math

def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().strip().split()
def SI(): return sys.stdin.readline().strip()
def MIN_INT(): return -1 * sys.maxsize
def MAX_INT(): return sys.maxsize
def prefSum(arr, n):
    P = [0] * (n + 1)
    for k in range(1, n + 1):
        P[k] = P[k - 1] + arr[k - 1]
    return P

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

def solve():
    n = II()
    if n <= 9:
        return n
    ans = [9]
    now = 9
    x = True
    while now < n and x:
        for i in range(1, ans[-1]):
            if now + i == n:
                ans.append(i)
                x = False
                break
            elif i == ans[-1]-1:
                now += i
                ans.append(i)
    for i in ans[::-1]:
        print(i,end='')
    print()

def main():
    t = II()
    for _ in range(t):
        solve()

main()