#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*/ LimpaBuffer();
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isalpha(char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ strrev(char *, int);
int main() {
  int NumCasos, Caso, Cont, TamPalav;
  char Palavra[1001];
  scanf("%d", &NumCasos);
  LimpaBuffer();
  for (Caso = 0; Caso < NumCasos; Caso++) {
    fgets(Palavra, 1001, stdin);
    for (Cont = 0; Palavra[Cont] >= ' '; Cont++)
      ;
    Palavra[Cont] = '\0';
    TamPalav = strlen(Palavra);
    strrev(Palavra, TamPalav);
    for (Cont = 0; Cont < TamPalav; Cont++) {
      if (isalpha(Palavra[Cont]) != 0)
        Palavra[Cont] = Palavra[Cont] + 3;
      if (Cont >= TamPalav / 2)
        Palavra[Cont] = Palavra[Cont] - 1;
    }
    printf("%s\n", Palavra);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1030 <LimpaBuffer@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12dd <main+0x16d>
lea    -0x400(%rbp),%rdi
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
mov    $0x3e9,%esi
call   1060 <fgets@plt>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jl     11f5 <main+0x85>
jmp    11e7 <main+0x77>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11cd <main+0x5d>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
lea    -0x400(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <strrev@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12bc <main+0x14c>
movslq -0x10(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%edi
ff
call   1070 <isalpha@plt>
cmp    $0x0,%rax
je     1269 <main+0xf9>
movslq -0x10(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
add    $0x3,%eax
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
mov    %eax,-0x404(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x404(%rbp),%eax
cmp    %ecx,%eax
jl     12a9 <main+0x139>
movslq -0x10(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
sub    $0x1,%eax
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
jmp    12ae <main+0x13e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1226 <main+0xb6>
lea    -0x400(%rbp),%rsi
lea    0xd39(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a0 <main+0x30>
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    0xe78(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
xor    %r12d,%r12d
xor    %eax,%eax
call   1030 <LimpaBuffer@plt>
cmpl   $0x0,0xc(%rsp)
jle    1270 <main+0x100>
lea    0x10(%rsp),%r15
lea    0xe50(%rip),%r14
jmp    11da <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
add    $0x1,%r12d
cmp    0xc(%rsp),%r12d
jge    1270 <main+0x100>
mov    0x2e07(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    $0x3e9,%esi
call   1060 <fgets@plt>
mov    $0xffffffffffffffff,%rax
nopw   0x0(%rax,%rax,1)
cmpb   $0x1f,0x11(%rsp,%rax,1)
lea    0x1(%rax),%rax
jg     1200 <main+0x90>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %eax,%esi
call   1090 <strrev@plt>
test   %ebx,%ebx
jle    11c0 <main+0x50>
mov    %ebx,%ebp
shr    %ebx
xor    %r13d,%r13d
jmp    124d <main+0xdd>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r13
cmp    %r13,%rbp
je     11c0 <main+0x50>
movsbl 0x10(%rsp,%r13,1),%edi
call   1070 <isalpha@plt>
test   %rax,%rax
je     1263 <main+0xf3>
addb   $0x3,0x10(%rsp,%r13,1)
cmp    %rbx,%r13
jb     1240 <main+0xd0>
addb   $0xff,0x10(%rsp,%r13,1)
jmp    1240 <main+0xd0>
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"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1001 x i8]
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = call i32 (...) @LimpaBuffer()
store i32 0, i32* %3
br label %9
9: ; preds = %82, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %85
13: ; preds = %9
%14 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %14, i32 1001, i32 %15)
store i32 0, i32* %4
br label %17
17: ; preds = %25, %13
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp sge i32 %22, 32
br i1 %23, label %24, label %28
24: ; preds = %17
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %17
28: ; preds = %17
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 %30
store i8 0, i8* %31
%32 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
store i32 %33, i32* %5
%34 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 0
%35 = load i32, i32* %5
%36 = call i32 @strrev(i8* %34, i32 %35)
store i32 0, i32* %4
br label %37
37: ; preds = %76, %28
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %79
41: ; preds = %37
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = call i64 @isalpha(i8 signext %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %59
48: ; preds = %41
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = add nsw i32 %53, 3
%55 = trunc i32 %54 to i8
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 %57
store i8 %55, i8* %58
br label %59
59: ; preds = %48, %41
%60 = load i32, i32* %4
%61 = load i32, i32* %5
%62 = sdiv i32 %61, 2
%63 = icmp sge i32 %60, %62
br i1 %63, label %64, label %75
64: ; preds = %59
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = sub nsw i32 %69, 1
%71 = trunc i32 %70 to i8
%72 = load i32, i32* %4
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 %73
store i8 %71, i8* %74
br label %75
75: ; preds = %64, %59
br label %76
76: ; preds = %75
%77 = load i32, i32* %4
%78 = add nsw i32 %77, 1
store i32 %78, i32* %4
br label %37
79: ; preds = %37
%80 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 0
%81 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %79
%83 = load i32, i32* %3
%84 = add nsw i32 %83, 1
store i32 %84, i32* %3
br label %9
85: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1001 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [1001 x i8], [1001 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = call i32 (...) @LimpaBuffer()
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %51
9: ; preds = %0, %46
%10 = phi i32 [ %48, %46 ], [ 0, %0 ]
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %4, i32 1001, i32 %11)
br label %13
13: ; preds = %13, %9
%14 = phi i64 [ %18, %13 ], [ 0, %9 ]
%15 = getelementptr inbounds [1001 x i8], [1001 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp sgt i8 %16, 31
%18 = add nuw i64 %14, 1
br i1 %17, label %13, label %19
19: ; preds = %13
%20 = and i64 %14, 4294967295
%21 = getelementptr inbounds [1001 x i8], [1001 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
%22 = call i32 @strlen(i8* %4)
%23 = call i32 @strrev(i8* %4, i32 %22)
%24 = icmp sgt i32 %22, 0
br i1 %24, label %25, label %46
25: ; preds = %19
%26 = lshr i32 %22, 1
%27 = zext i32 %26 to i64
%28 = zext i32 %22 to i64
br label %29
29: ; preds = %25, %43
%30 = phi i64 [ 0, %25 ], [ %44, %43 ]
%31 = getelementptr inbounds [1001 x i8], [1001 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = call i64 @isalpha(i8 signext %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %29
%36 = load i8, i8* %31
%37 = add i8 %36, 3
store i8 %37, i8* %31
br label %38
38: ; preds = %35, %29
%39 = icmp ult i64 %30, %27
br i1 %39, label %43, label %40
40: ; preds = %38
%41 = load i8, i8* %31
%42 = add i8 %41, -1
store i8 %42, i8* %31
br label %43
43: ; preds = %38, %40
%44 = add nuw nsw i64 %30, 1
%45 = icmp eq i64 %44, %28
br i1 %45, label %46, label %29
46: ; preds = %43, %19
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%48 = add nuw nsw i32 %10, 1
%49 = load i32, i32* %1
%50 = icmp slt i32 %48, %49
br i1 %50, label %9, label %51
51: ; preds = %46, %0
ret i32 0
}