// Arup Guha
// 1/9/2017

// This program reads from standard input an integer (number of cases)
// and each case is a single integer. The program then prints out each
// k-digit divisible number in numeric order. A k-digit divisible number
// is one where the first digit by itself is divisible by 1, the first two
// digits (as a 2 digit number) are divisible by 2, and so forth, up to k,
// with no leading 0s.

import java.util.*;

public class kdiv {

	public static int numDigits;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<nC; loop++) {
			numDigits = stdin.nextInt();
			printkDiv(0, 0);
		}
	}

	public static void printkDiv(int curNum, int k) {

		// Finished filling out a number, print it out.
		if (k == numDigits) {
			System.out.println(curNum);
			return;
		}

		// Set start tp either 0 or 1 depending on what k is.
		int start = k > 0 ? 0 : 1;

		// Try each digit as the next one.
		for (int i=start; i<10; i++) {

			// Calculate what the next number would be.
			int newNum = curNum*10 + i;

			// Skip it if it's not divisible by k+1.
			if (newNum%(k+1) != 0) continue;

			// If we get here, we want to print all numDigit-digit divisible numbers
			// that start with newNum.
			printkDiv(newNum, k+1);
		}
	}
}