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 <complex>
#include <iostream>
#include <vector>

typedef unsigned long long ull;

using namespace std;

typedef unsigned long long ull;

ull reduce(ull x) {
    if (x < 10) {
        return x;
    }
    ull mul = 1;
    while (x != 0) {
        mul *= (x % 10);
        x /= 10;
    }
    return reduce(mul);
}

int main() {
    ios_base::sync_with_stdio(false);
    ull n, t;
    cin >> t;

    while (t--) {
        vector<ull> counts(10);
        cin >> n;
        for (ull i = 1; i <= n; i++) {
            counts[reduce(i)] += 1;
        }
        for (int j = 0; j < 10; j++) {
            cout << counts[j] << " ";
        }
        cout << endl;
    }
    return 0;
}