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 JAVA):

Solution:
import java.util.*;
// import java.lang.*;
import java.io.*;

//           THIS TEMPLATE MADE BY AKSH BANSAL.

public class Solution {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        // ________________________________

        int t = sc.nextInt();
        // StringBuilder output = new StringBuilder();

        while (t-- > 0) {
            int n = sc.nextInt();
            // String s = sc.nextLine();
            solver(n, out);
            // out.println();
        }

        // out.println(output);
        // _______________________________

        // int n = sc.nextInt();
        // out.println(solver());
        // ________________________________
        out.flush();
    }

    private static int[][] dp = new int[45][9];

    public static void solver(int n, PrintWriter out) {
        if(n>45){
            out.println(-1);
            return;
        }else if(n<10){
            out.println(n);
            return;
        }else if(n<=17){
            //2 digit
             out.print(helper(n, 1, new boolean[10]));
            out.println();
 

        }else if(n<=24){
            //3digit
             out.print(helper(n, 2, new boolean[10]));

            out.println();
 

        }else if(n<=30){
            //4digit
             out.print(helper(n, 3, new boolean[10]));
           out.println();
 

        }else if(n<=35){
            //5digit
             out.print(helper(n, 4, new boolean[10]));
           out.println();
        }else if(n<=39){
            //6 digit
             out.print(helper(n, 5, new boolean[10]));
            out.println();
        }else if(n<=42){
            //7digit
             out.print(helper(n, 6, new boolean[10]));
 
            out.println();
        }else if(n<=44){
            //8digit
             out.print(helper(n, 7, new boolean[10]));
            out.println();
        }else if(n<=45){
            //9 digit
            out.println("123456789");
        }
    }

    private static int helper(int n, int d, boolean[] vis){
        if(n>(d+1)*9 || n<1 || d<0)return 0;
       
        else if(d==0){
            return vis[n]?0:n;
        }
        else {
            for(int i=1;i<=9;i++){
                if(!vis[i]){
                    vis[i] = true;
                    int temp = i*(int)Math.pow(10,d)+helper(n-i,d-1, vis);
                    vis[i] = false;
                    // System.out.println(temp+"__"+n);
                    if(temp!=i*(int)Math.pow(10,d)){
                        return temp;
                    }
                }
                
            }
            return 0;
        }
    }
}