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
#include <iostream>
#include <vector>
#include <list>
#include <tuple>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long int lli;

int countMulti(lli numb) {
    while ( numb > 9 ) {
        lli res = 1;
        string str = to_string(numb);
        for ( char c : str ) {
            res *= (c - '0');
        }
        numb = res;
    }
    return numb;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    vector<lli> res(10);

    int t;
    cin >> t; 
    while (t--) {
        lli n;
        cin >> n;

        for ( int i = 0; i < 10; ++i ) res[i] = 0;

        for ( int i = 1; i <= n; ++i ) {
            int r = countMulti(i);
            res[r]++;
        }
        for ( int j = 0; j < 10; ++j) {
            cout << res[j] << " ";
        }
        cout << "\n";
    }
    return 0;
}