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
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int t; // liczba dni

ll multiply_digits(ll x) {
    ll y = x;
    ll res = 1;
    ll pow = 1;
    while (pow <= x) pow *= 10;
    pow /= 10;
    for (pow; pow; pow /= 10) {
        ll digit = y / pow;
        y = y % pow;
        res *= digit;
    }
    return res;
}

ll to_one_digit(ll x) {
    while (x >= 10) x = multiply_digits(x);
    return x;
}

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

    cin >> t;

    for (int i=0; i<t; i++) {
        ll n;
        cin >> n;
        vector<ll> cnt(10, 0);
        for (ll j=1; j<=n; j++) cnt[to_one_digit(j)]++;
        for (ll c: cnt) cout << c << ' ';
        cout << '\n';
    }
}