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.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class UniqueNumber {


    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        StringTokenizer tokenizer;

        tokenizer = new StringTokenizer(reader.readLine());
        int numTests = Integer.parseInt(tokenizer.nextToken());

        for (int i = 0; i < numTests; i++) {
            int x = Integer.parseInt(reader.readLine());
            String output = dp(1, x, new String[10][x+1]);
            if(output.length() > 9){
                writer.write(Integer.toString(-1));
                writer.newLine();
                writer.flush();
                continue;
            }
            int[] nums = new int[output.length()];
            for(int j = 0; j<nums.length; j++){
                nums[j] = Character.getNumericValue(output.charAt(j));
            }

            Arrays.sort(nums);
            for(int j = 0; j<nums.length; j++){
                writer.write(Integer.toString(nums[j]));
            }
            writer.newLine();
            writer.flush();
        }
    }


    public static String dp(int i, int total, String[][] sols){
        if(i>total || i > 9){
            return "1234567890";
        } else if(i == total){
            return Integer.toString(i);
        } else if(sols[i][total] != null){
            return sols[i][total];
        }
        String option1 = Integer.toString(i) + dp(i+1, total-i, sols);
        String option2 = dp(i+1, total, sols);
        if(option1.length() <= option2.length()){
            sols[i][total] = option1;
        } else {
            sols[i][total] = option2;
        }

        return sols[i][total];
    }
}