1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
typedef int ll;
typedef short int sint;

using namespace std;

constexpr ll mxV = 1e7;

vector<vector<ll>> l(mxV + 1, vector<ll>(10));

ll liczba(ll n)
{
	ll newN = 1;

	while (n > 9)
	{
		do {
			newN *= n % 10;
			n /= 10;
		} while (n > 0);

		n = newN;
		newN = 1;
	}

	return n;
}

int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);

	for (ll i = 1; i <= mxV; ++i)
	{
		for (ll j = 0; j <= 9; ++j)
			l[i][j] = l[i - 1][j];
		++l[i][liczba(i)];
	}

	int t, a;
	cin >> t;

	for (int i = 0; i < t; ++i)
	{
		cin >> a;

		for (int j = 0; j <= 9; ++j)
			cout << l[a][j] << ' ';
		cout << '\n';
	}

	return 0;
}