#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, char);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, T, count[10], num, temp;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &num);
    memset(count, 0, sizeof(int) * 10);
    for (i = 1; i <= num; i++) {
      temp = i;
      while (temp) {
        count[temp % 10]++;
        temp /= 10;
      }
    }
    for (i = 0; i < 10; i++)
      printf("%d%c", count[i], i == 9 ? '\n' : ' ');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1233 <main+0x103>
lea    0xe96(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x44(%rbp),%eax
jg     11e5 <main+0xb5>
mov    -0x8(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     11d2 <main+0xa2>
mov    -0x48(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x48(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x48(%rbp)
jmp    119c <main+0x6c>
jmp    11d7 <main+0xa7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118a <main+0x5a>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    122e <main+0xfe>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
mov    -0x8(%rbp),%edx
mov    $0x20,%eax
mov    $0xa,%ecx
cmp    $0x9,%edx
cmove  %ecx,%eax
lea    0xdeb(%rip),%rdi
movsbl %al,%edx
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ec <main+0xbc>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
lea    0xebc(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
subl   $0x1,0x8(%rsp)
jae    1165 <main+0x35>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe94(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe86(%rip),%r13
jmp    1245 <main+0x115>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x28(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x30(%rsp),%esi
mov    %r13,%rdi
mov    $0x20,%edx
call   1030 <printf@plt>
mov    0x34(%rsp),%esi
mov    %r13,%rdi
mov    $0xa,%edx
call   1030 <printf@plt>
subl   $0x1,0x8(%rsp)
jb     1155 <main+0x25>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1190 <main+0x60>
mov    $0x1,%ecx
mov    %ecx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %edx,%rsi
imul   $0x66666667,%rsi,%rdx
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rdx
add    %edi,%edx
lea    (%rdx,%rdx,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %esi,%ebx
sub    %edi,%ebx
movslq %ebx,%rdi
addl   $0x1,0x10(%rsp,%rdi,4)
add    $0x9,%esi
cmp    $0x12,%esi
ja     1280 <main+0x150>
lea    0x1(%rcx),%edx
cmp    %eax,%ecx
mov    %edx,%ecx
jne    1270 <main+0x140>
jmp    1190 <main+0x60>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %8
8: ; preds = %56, %0
%9 = load i32, i32* %3
%10 = add nsw i32 %9, -1
store i32 %10, i32* %3
%11 = icmp ne i32 %9, 0
br i1 %11, label %12, label %57
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%15 = call i32 @memset(i32* %14, i32 0, i32 40)
store i32 1, i32* %2
br label %16
16: ; preds = %35, %12
%17 = load i32, i32* %2
%18 = load i32, i32* %5
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %38
20: ; preds = %16
%21 = load i32, i32* %2
store i32 %21, i32* %6
br label %22
22: ; preds = %25, %20
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %6
%27 = srem i32 %26, 10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
%32 = load i32, i32* %6
%33 = sdiv i32 %32, 10
store i32 %33, i32* %6
br label %22
34: ; preds = %22
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %16
38: ; preds = %16
store i32 0, i32* %2
br label %39
39: ; preds = %53, %38
%40 = load i32, i32* %2
%41 = icmp slt i32 %40, 10
br i1 %41, label %42, label %56
42: ; preds = %39
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %2
%48 = icmp eq i32 %47, 9
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 10, i32 32
%51 = trunc i32 %50 to i8
%52 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %46, i8 signext %51)
br label %53
53: ; preds = %42
%54 = load i32, i32* %2
%55 = add nsw i32 %54, 1
store i32 %55, i32* %2
br label %39
56: ; preds = %39
br label %8
57: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast [10 x i32]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %66, label %11
11: ; preds = %0
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 2
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 3
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 4
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 5
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 6
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 7
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 8
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
br label %22
22: ; preds = %11, %27
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%24 = call i32 @memset(i32* %12, i32 0, i32 40)
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 1
br i1 %26, label %27, label %51
27: ; preds = %63, %22
%28 = load i32, i32* %12
%29 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %28, i8 signext 32)
%30 = load i32, i32* %13
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8 signext 32)
%32 = load i32, i32* %14
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %32, i8 signext 32)
%34 = load i32, i32* %15
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34, i8 signext 32)
%36 = load i32, i32* %16
%37 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %36, i8 signext 32)
%38 = load i32, i32* %17
%39 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %38, i8 signext 32)
%40 = load i32, i32* %18
%41 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %40, i8 signext 32)
%42 = load i32, i32* %19
%43 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %42, i8 signext 32)
%44 = load i32, i32* %20
%45 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %44, i8 signext 32)
%46 = load i32, i32* %21
%47 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %46, i8 signext 10)
%48 = load i32, i32* %1
%49 = add nsw i32 %48, -1
store i32 %49, i32* %1
%50 = icmp eq i32 %48, 0
br i1 %50, label %66, label %22
51: ; preds = %22, %63
%52 = phi i32 [ %64, %63 ], [ 1, %22 ]
br label %53
53: ; preds = %51, %53
%54 = phi i32 [ %52, %51 ], [ %60, %53 ]
%55 = srem i32 %54, 10
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %57
%60 = sdiv i32 %54, 10
%61 = add i32 %54, 9
%62 = icmp ult i32 %61, 19
br i1 %62, label %63, label %53
63: ; preds = %53
%64 = add nuw i32 %52, 1
%65 = icmp eq i32 %52, %25
br i1 %65, label %27, label %51
66: ; preds = %27, %0
ret i32 0
}