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<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#define ll long long
using namespace std;

int fun(ll x){
    if(x<10){
        return x;
    }
    ll a = 1;
    while(x>0){
        a*=(x%10);
        x/=10;
    }
    return fun(a);
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t; cin>>t;
    for(int T = 0;T<t;++T){
        ll n;
        cin>>n;
        vector<ll>tab(10,0);
        for(ll i = 1;i<=n;i++){
            tab[fun(i)]++;
        }
        for(int i = 0;i<10;++i){
            cout<<tab[i]<<" ";
        }
        cout<<"\n";
    }
    return 0;

}