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>
using namespace std;
#define int long long
// pair_hash z https://stackoverflow.com/questions/32685540/why-cant-i-compile-an-unordered-map-with-a-pair-as-key
struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};


unordered_map<pair<int,int>,int, pair_hash> ans;
unordered_map<long long,long long> um;

int simulate(int n){
    if(um.contains(n)){
        return um[n];
    }
    string x = to_string(n);
    int ans2 = 1;
    for(auto z : x){
        ans2 *= z-48;
    }
    if(ans2 <= 9){
        return ans2;
    }
    int q = simulate(ans2);
    um[ans2] = q;
    um[n] = q;
    return q;
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    for(int i = 0; i<t; i++){
        int x;
        cin >> x;
        for(int q = 1; q<=x; q++){
            ans[{i,simulate(q)}]++;
        }
        for(int q = 0; q<=9; q++){
            cout << ans[{i,simulate(q)}] << " ";
        }
        cout << "\n";
    }
}