#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int aux = 97, i, k = 0, n;
  int frase_aux[200];
  char letra, frase[200];
  scanf("%d", &n);
  getchar();
  for (; n > 0; --n) {
    scanf("%c", &letra);
    while (letra != '\n') {
      frase[k] = letra;
      for (i = 0; i < k; ++i) {
        if (letra == frase[i]) {
          printf("%c", (char)frase_aux[i]);
          frase_aux[k] = frase_aux[i];
          break;
        }
      }
      if (i == k) {
        printf("%c", (char)aux);
        frase_aux[k] = aux;
        ++aux;
      }
      ++k;
      scanf("%c", &letra);
    }
    printf("\n");
    k = 0;
    aux = 97;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x61,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea9(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
cmpl   $0x0,-0x14(%rbp)
jle    12a5 <main+0x175>
lea    0xe89(%rip),%rdi
lea    -0x341(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x341(%rbp),%eax
cmp    $0xa,%eax
je     127b <main+0x14b>
mov    -0x341(%rbp),%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1221 <main+0xf1>
movsbl -0x341(%rbp),%eax
movslq -0xc(%rbp),%rcx
movsbl -0x410(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    120e <main+0xde>
movslq -0xc(%rbp),%rax
mov    -0x340(%rbp,%rax,4),%eax
movsbl %al,%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
mov    -0x340(%rbp,%rax,4),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x340(%rbp,%rax,4)
jmp    1221 <main+0xf1>
jmp    1213 <main+0xe3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b0 <main+0x80>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1258 <main+0x128>
mov    -0x8(%rbp),%eax
movsbl %al,%esi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x340(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xd9b(%rip),%rdi
lea    -0x341(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
jmp    1188 <main+0x58>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x61,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <main+0x39>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xeb8(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmpl   $0x0,0x8(%rsp)
jle    1288 <main+0x158>
lea    0xe96(%rip),%r14
lea    0x7(%rsp),%r15
jmp    119e <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
cmp    $0x1,%eax
jle    1288 <main+0x158>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x7(%rsp),%al
cmp    $0xa,%al
je     1180 <main+0x50>
mov    $0x61,%r12d
mov    $0xffffffff,%r13d
xor    %ebp,%ebp
jmp    11ed <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x7(%rsp),%al
add    $0x1,%r13d
cmp    $0xa,%al
je     1180 <main+0x50>
mov    %al,0x10(%rsp,%rbp,1)
test   %rbp,%rbp
je     1220 <main+0xf0>
lea    0x1(%r13),%ecx
xor    %ebx,%ebx
nopl   0x0(%rax)
cmp    0x10(%rsp,%rbx,1),%al
je     1230 <main+0x100>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1200 <main+0xd0>
jmp    1263 <main+0x133>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
jmp    1263 <main+0x133>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%eax
mov    %r12d,0xc(%rsp)
mov    %r15,%r12
mov    %r14,%r15
mov    0xe0(%rsp,%rax,4),%r14d
movsbl %r14b,%edi
call   1030 <putchar@plt>
mov    %r14d,0xe0(%rsp,%rbp,4)
mov    %r15,%r14
mov    %r12,%r15
mov    0xc(%rsp),%r12d
mov    %ebx,%ecx
mov    %ecx,%eax
cmp    %rax,%rbp
jne    11d0 <main+0xa0>
movsbl %r12b,%edi
call   1030 <putchar@plt>
mov    %r12d,0xe0(%rsp,%rbp,4)
add    $0x1,%r12d
jmp    11d0 <main+0xa0>
xor    %eax,%eax
add    $0x408,%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 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [200 x i32]
%7 = alloca i8
%8 = alloca [200 x i8]
store i32 0, i32* %1
store i32 97, i32* %2
store i32 0, i32* %4
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%10 = call i32 (...) @getchar()
br label %11
11: ; preds = %78, %0
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %81
14: ; preds = %11
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %16
16: ; preds = %72, %14
%17 = load i8, i8* %7
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %76
20: ; preds = %16
%21 = load i8, i8* %7
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %23
store i8 %21, i8* %24
store i32 0, i32* %3
br label %25
25: ; preds = %54, %20
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %57
29: ; preds = %25
%30 = load i8, i8* %7
%31 = sext i8 %30 to i32
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %31, %36
br i1 %37, label %38, label %53
38: ; preds = %29
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [200 x i32], [200 x i32]* %6, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = trunc i32 %42 to i8
%44 = sext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [200 x i32], [200 x i32]* %6, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [200 x i32], [200 x i32]* %6, i64 0, i64 %51
store i32 %49, i32* %52
br label %57
53: ; preds = %29
br label %54
54: ; preds = %53
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %25
57: ; preds = %38, %25
%58 = load i32, i32* %3
%59 = load i32, i32* %4
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %72
61: ; preds = %57
%62 = load i32, i32* %2
%63 = trunc i32 %62 to i8
%64 = sext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %64)
%66 = load i32, i32* %2
%67 = load i32, i32* %4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [200 x i32], [200 x i32]* %6, i64 0, i64 %68
store i32 %66, i32* %69
%70 = load i32, i32* %2
%71 = add nsw i32 %70, 1
store i32 %71, i32* %2
br label %72
72: ; preds = %61, %57
%73 = load i32, i32* %4
%74 = add nsw i32 %73, 1
store i32 %74, i32* %4
%75 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %16
76: ; preds = %16
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
store i32 97, i32* %2
br label %78
78: ; preds = %76
%79 = load i32, i32* %5
%80 = add nsw i32 %79, -1
store i32 %80, i32* %5
br label %11
81: ; preds = %11
ret i32 0
}

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