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
def multiply_digits(x):
    while x >= 10:
        new_x = 1
        while x > 0:
            new_x *= x % 10
            x //= 10
        x = new_x
    return x


def solve(t, n_values):
    # Lista przechowująca dla każdego dnia, ile razy każda cyfra pojawiła się jako wynik
    results = []

    # Przechodzimy przez wszystkie dni
    for n in n_values:
        counts = [0] * 10
        for i in range(1, n + 1):
            result = multiply_digits(i)
            counts[result] += 1
        results.append(counts)

    # Wypisujemy wyniki
    for count in results:
        print(" ".join(map(str, count)))


# Wczytanie danych wejściowych
t = int(input())
n_values = list(map(int, input().split()))

# Wywołanie funkcji rozwiązującej
solve(t, n_values)