#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ getchar();
scalar_t__ gets(char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int strlen(char *);
int main() {
  char a[120];
  int t, len, i, j, l;
  while (scanf("%d", &t) == 1) {
    getchar();
    for (j = 1; j <= t; j++) {
      while (gets(a)) {
        len = strlen(a);
        if (len == 0)
          break;
        for (i = 0; a[i] != '\0'; i++) {
          if (a[i] == '0')
            printf("O");
          else if (a[i] == '1')
            printf("I");
          else if (a[i] == '2')
            printf("Z");
          else if (a[i] == '3')
            printf("E");
          else if (a[i] == '4')
            printf("A");
          else if (a[i] == '5')
            printf("S");
          else if (a[i] == '6')
            printf("G");
          else if (a[i] == '7')
            printf("T");
          else if (a[i] == '8')
            printf("B");
          else if (a[i] == '9')
            printf("P");
          else
            printf("%c", a[i]);
        }
        printf("\n");
        memset(a, '\0', sizeof(a));
      }
      if (j != t)
        printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    -0x84(%rbp),%rsi
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    145a <main+0x2fa>
mov    $0x0,%al
call   1060 <getchar@plt>
movl   $0x1,-0x90(%rbp)
mov    -0x90(%rbp),%eax
cmp    -0x84(%rbp),%eax
jg     1455 <main+0x2f5>
jmp    11b6 <main+0x56>
lea    -0x80(%rbp),%rdi
call   1070 <gets@plt>
cmp    $0x0,%rax
je     141c <main+0x2bc>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x0,-0x88(%rbp)
jne    11ea <main+0x8a>
jmp    141c <main+0x2bc>
movl   $0x0,-0x8c(%rbp)
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     13f9 <main+0x299>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jne    1231 <main+0xd1>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13e0 <main+0x280>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x31,%eax
jne    1259 <main+0xf9>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13db <main+0x27b>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x32,%eax
jne    1281 <main+0x121>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d6 <main+0x276>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x33,%eax
jne    12a9 <main+0x149>
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d1 <main+0x271>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x34,%eax
jne    12d1 <main+0x171>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13cc <main+0x26c>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x35,%eax
jne    12f9 <main+0x199>
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13c7 <main+0x267>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x36,%eax
jne    1321 <main+0x1c1>
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13c2 <main+0x262>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x37,%eax
jne    1349 <main+0x1e9>
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13bd <main+0x25d>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x38,%eax
jne    1371 <main+0x211>
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13b8 <main+0x258>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jne    1399 <main+0x239>
lea    0xc88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13b3 <main+0x253>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%esi
lea    0xc6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13b8 <main+0x258>
jmp    13bd <main+0x25d>
jmp    13c2 <main+0x262>
jmp    13c7 <main+0x267>
jmp    13cc <main+0x26c>
jmp    13d1 <main+0x271>
jmp    13d6 <main+0x276>
jmp    13db <main+0x27b>
jmp    13e0 <main+0x280>
jmp    13e5 <main+0x285>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    11f4 <main+0x94>
lea    0xc1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x78,%edx
call   1050 <memset@plt>
jmp    11b6 <main+0x56>
mov    -0x90(%rbp),%eax
cmp    -0x84(%rbp),%eax
je     143c <main+0x2dc>
lea    0xbe5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1441 <main+0x2e1>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    119f <main+0x3f>
jmp    1172 <main+0x12>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xf70(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    12ad <main+0x14d>
lea    0xf56(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe5d(%rip),%rbx
jmp    11c4 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    12ad <main+0x14d>
xor    %eax,%eax
call   1060 <getchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    11b0 <main+0x50>
mov    $0x1,%r13d
jmp    11f9 <main+0x99>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x78,%edx
call   1050 <memset@plt>
mov    %r12,%rdi
call   1070 <gets@plt>
test   %rax,%rax
je     1280 <main+0x120>
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     1280 <main+0x120>
mov    %r12,%rbp
jmp    1229 <main+0xc9>
movsbl %al,%edi
nopw   0x0(%rax,%rax,1)
call   1030 <putchar@plt>
add    $0x1,%rbp
movzbl 0x0(%rbp),%eax
cmp    $0x39,%rax
ja     1217 <main+0xb7>
mov    $0x4f,%edi
movslq (%rbx,%rax,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
mov    $0x49,%edi
jmp    1220 <main+0xc0>
mov    $0x5a,%edi
jmp    1220 <main+0xc0>
mov    $0x45,%edi
jmp    1220 <main+0xc0>
mov    $0x41,%edi
jmp    1220 <main+0xc0>
mov    $0x53,%edi
jmp    1220 <main+0xc0>
mov    $0x47,%edi
jmp    1220 <main+0xc0>
mov    $0x54,%edi
jmp    1220 <main+0xc0>
mov    $0x42,%edi
jmp    1220 <main+0xc0>
mov    $0x50,%edi
jmp    1220 <main+0xc0>
mov    %r13d,%eax
cmp    0xc(%rsp),%r13d
je     1298 <main+0x138>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
lea    0x1(%r13),%ecx
cmp    %eax,%r13d
mov    %ecx,%r13d
jl     11f9 <main+0x99>
jmp    11b0 <main+0x50>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"O\00"
@.str.2 = [2 x i8] c"I\00"
@.str.3 = [2 x i8] c"Z\00"
@.str.4 = [2 x i8] c"E\00"
@.str.5 = [2 x i8] c"A\00"
@.str.6 = [2 x i8] c"S\00"
@.str.7 = [2 x i8] c"G\00"
@.str.8 = [2 x i8] c"T\00"
@.str.9 = [2 x i8] c"B\00"
@.str.10 = [2 x i8] c"P\00"
@.str.11 = [3 x i8] c"%c\00"
@.str.12 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [120 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
br label %8
8: ; preds = %160, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %161
11: ; preds = %8
%12 = call i32 (...) @getchar()
store i32 1, i32* %6
br label %13
13: ; preds = %157, %11
%14 = load i32, i32* %6
%15 = load i32, i32* %3
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %160
17: ; preds = %13
br label %18
18: ; preds = %146, %17
%19 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%20 = call i64 @gets(i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %150
22: ; preds = %18
%23 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
br label %150
28: ; preds = %22
store i32 0, i32* %5
br label %29
29: ; preds = %143, %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %146
36: ; preds = %29
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 48
br i1 %42, label %43, label %45
43: ; preds = %36
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %142
45: ; preds = %36
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 49
br i1 %51, label %52, label %54
52: ; preds = %45
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %141
54: ; preds = %45
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 50
br i1 %60, label %61, label %63
61: ; preds = %54
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %140
63: ; preds = %54
%64 = load i32, i32* %5
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 51
br i1 %69, label %70, label %72
70: ; preds = %63
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %139
72: ; preds = %63
%73 = load i32, i32* %5
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 52
br i1 %78, label %79, label %81
79: ; preds = %72
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %138
81: ; preds = %72
%82 = load i32, i32* %5
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 53
br i1 %87, label %88, label %90
88: ; preds = %81
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %137
90: ; preds = %81
%91 = load i32, i32* %5
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 54
br i1 %96, label %97, label %99
97: ; preds = %90
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %136
99: ; preds = %90
%100 = load i32, i32* %5
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %101
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = icmp eq i32 %104, 55
br i1 %105, label %106, label %108
106: ; preds = %99
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %135
108: ; preds = %99
%109 = load i32, i32* %5
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %110
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 56
br i1 %114, label %115, label %117
115: ; preds = %108
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %134
117: ; preds = %108
%118 = load i32, i32* %5
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %119
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
%123 = icmp eq i32 %122, 57
br i1 %123, label %124, label %126
124: ; preds = %117
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %133
126: ; preds = %117
%127 = load i32, i32* %5
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 %128
%130 = load i8, i8* %129
%131 = sext i8 %130 to i32
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 %131)
br label %133
133: ; preds = %126, %124
br label %134
134: ; preds = %133, %115
br label %135
135: ; preds = %134, %106
br label %136
136: ; preds = %135, %97
br label %137
137: ; preds = %136, %88
br label %138
138: ; preds = %137, %79
br label %139
139: ; preds = %138, %70
br label %140
140: ; preds = %139, %61
br label %141
141: ; preds = %140, %52
br label %142
142: ; preds = %141, %43
br label %143
143: ; preds = %142
%144 = load i32, i32* %5
%145 = add nsw i32 %144, 1
store i32 %145, i32* %5
br label %29
146: ; preds = %29
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%148 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%149 = call i32 @memset(i8* %148, i8 signext 0, i32 120)
br label %18
150: ; preds = %27, %18
%151 = load i32, i32* %6
%152 = load i32, i32* %3
%153 = icmp ne i32 %151, %152
br i1 %153, label %154, label %156
154: ; preds = %150
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %156
156: ; preds = %154, %150
br label %157
157: ; preds = %156
%158 = load i32, i32* %6
%159 = add nsw i32 %158, 1
store i32 %159, i32* %6
br label %13
160: ; preds = %13
br label %8
161: ; preds = %8
ret i32 0
}

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