# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cstring>
# include <queue>
using namespace std;

unsigned long long Input;
const int BASE = 100000;
bool exist[20000];

class BigInteger
{
public:
    int num[10];
	int len;
	BigInteger& mul10()
	{
		int c = 0;
		for(int i=0;i<len;i++)
		{
			num[i] = num[i]*10 + c;
			c = num[i]/BASE;
			num[i]%=BASE;
		}
		if(c)
		{
			num[len++] = c;
		}
		return *this;
	}
	BigInteger& add(int c)
	{
		for(int i=0;c&&i<len;i++)
		{
			num[i] = num[i] + c;
			c = num[i]/BASE;
			num[i]%=BASE;
		}
		if(c)
		{
			num[len++] = c;
		}
		return *this;
	}
	int operator%(const int& a)
	{
		int c = 0;
		for(int i=len-1;i>=0;i--)
		{
			c*=BASE;
			c+=num[i];
			c%=a;
		}
		return c;
	}
};

ostream& operator<<(ostream& out, const BigInteger& a)
{
	out << a.num[a.len-1];
	for(int i=a.len-2;i>=0;i--)
	{
		out << right << setfill('0') << setw(5) << a.num[i];
	}
	return out;
}

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	BigInteger current;
	queue <BigInteger> Queue;
	BigInteger ten;
	ten.len = 1;
	ten.num[0] = 10;
	BigInteger eleven;
	eleven.len = 1;
	eleven.num[0] = 11;
	int maxlen = -1,j=-1;
	for (int i = 1; i <= N; i++)
	{
		cin >> Input;
		memset(exist,0,sizeof(exist));
		if (Input == 1) {cout << "1" << endl; continue;}
		Queue.push (ten); Queue.push (eleven);
		while (!Queue.empty())
		{
			current = Queue.front();
			Queue.pop();
			int temp = current % Input;
			if(exist[temp]) continue;
			exist[temp] = 1;
			if (temp)
			{
				Queue.push (current.mul10());
				Queue.push (current.add(1));
			}
			else
			{
				cout << current << endl;
				while (!Queue.empty()) Queue.pop();
			}
		}
	}
	return 0;
}