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

/* ------------ Theorems and Lemmas ------------ */

// Fermat's Little Theorem
// (1) ((a ** p) - a) % p = 0; if 'p' is prime
// (2) Further, if 'a % p != 0', then ((a ** (p - 1)) - 1) % p = 0

/* -------------- End of theorems -------------- */

public class Solution {

	// Digit DP
	private static int digit;
	private static int times;
	private static StringBuilder number;
	private static int[][][] digitDP;
	// End

	public static void main(String[] args) {
		FastReader reader = new FastReader();
		int t = reader.nextInt();
		while (t-- > 0) {
			int x = reader.nextInt();
			if (x > 45)
				System.out.println(-1);
			else {
				StringBuilder sb = new StringBuilder("");
				int num = 9;
				while (x > 0) {
					sb.append(Math.min(num, x));
					x -= Math.min(num--, x);
				}
				System.out.println(sb.reverse());
			}
		}
		reader.close();
	}

	// Digit DP
	public static int ddp(int n) {
		number = new StringBuilder(String.valueOf(n));
		digitDP = new int[12][12][2];
		for (int[][] a : digitDP)
			for (int[] b : a)
				Arrays.fill(b, -1);
		return call(0, 0, 0);
	}

	// Digit DP
	public static int call(int pos, int cnt, int f) {
		if (cnt > times)
			return 0;
		if (pos == number.length())
			return cnt == times ? 1 : 0;
		if (digitDP[pos][cnt][f] != -1)
			return digitDP[pos][cnt][f];
		int res = 0;
		int lmt = f == 0 ? number.charAt(pos) - '0' : 9;
		for (int dgt = 0; dgt <= lmt; ++dgt) {
			int nf = f;
			int ncnt = cnt;
			if (f == 0 && dgt < lmt)
				nf = 1;
			if (dgt == digit)
				++ncnt;
			if (ncnt <= times)
				res += call(1 + pos, ncnt, nf);
		}
		digitDP[pos][cnt][f] = res;
		return res;
	}

	// Binary Exponentiation
	public static long binpow(long a, long n, long mod) {
		// Iterative approach
		a %= mod;
		long result = 1l;
		while (n > 0l) {
			if ((n & 1l) != 0l)
				result = result * a % mod;
			a = a * a % mod;
			n >>= 1l;
		}
		return result;

		// Recursive approach
		/*
		 * if (n == 0l) return 1l; long res = binpow(a, n / 2, mod); if ((n & 1l) != 0l)
		 * return ((res % mod) * (res % mod) * (a % mod)) % mod; else return ((res %
		 * mod) * (res % mod)) % mod;
		 */
	}

	// GCD
	public static int gcd(int a, int b) {
		while (b > 0) {
			a %= b;
			int t = a;
			a = b;
			b = t;
		}
		return a;
	}

	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().trim());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		float nextFloat() {
			return Float.parseFloat(next());
		}

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

		String nextLine() {
			StringBuilder str = new StringBuilder("");
			try {
				str.append(br.readLine().trim());
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str.toString();
		}

		long[] readArray(int size) {
			long[] ar = new long[size];
			for (int i = 0; i < size; ++i)
				ar[i] = nextLong();
			return ar;
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}