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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <vector>
#include <array>
#include <sstream>

using namespace std;

long iloczynCyfr(long n) {
    if (n == 0) return 0;
    long iloczyn = 1;

    while (n > 0) {
        int cyfra = n % 10;
        iloczyn *= cyfra;
        if (iloczyn == 0) break;
        n /= 10;
    }
    return iloczyn;
}

int lastIloczyn(long n) {
    long iloczyn = iloczynCyfr(n);
    while (iloczyn > 9) {
        iloczyn = iloczynCyfr(iloczyn);
    }
    return iloczyn;
}

string arrayToString(array<long, 10> a) {
    ostringstream oss;
    for (int i = 0; i < 10; i++) {
        oss << a[i];
        if (i != 9) {
            oss << ' ';
        }
    }
    return oss.str();
}

int main()
{
    int t;
    cin >> t;

    long tmax = 0;
    vector<long> days;
    for (int i = 0; i < t; i++) {
        long x;
        cin >> x;
        days.push_back(x);
        if (x > tmax) tmax = x;
    }

	array<long, 10> hist = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    vector<string> tab;

    for (long g = 1; g <= tmax; g++) {
        int wynik = lastIloczyn(g);
        hist[wynik]++;
        string h = arrayToString(hist);
        tab.push_back(h);
        //cout << g << ". " << h << endl;
    }

    for (int i = 0; i < t; i++) {
        cout << tab[days[i] - 1] << endl;
    }

}