#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  int intCmd;
  scanf("%d", &intCmd);
  int setNum = 1;
  while (intCmd) {
    int iter;
    char chSet[16][32];
    char str[32];
    int arrHead = 0, arrTail = intCmd - 1;
    for (iter = 0; iter < intCmd; ++iter) {
      scanf("%s", str);
      if (iter % 2 == 0) {
        strncpy(chSet[arrHead], str, strlen(str) + 1);
        chSet[arrHead][strlen(str)] = '\0';
        ++arrHead;
      } else {
        strncpy(chSet[arrTail], str, strlen(str) + 1);
        chSet[arrTail][strlen(str)] = '\0';
        --arrTail;
      }
    }
    printf("SET %d\n", setNum);
    for (iter = 0; iter < intCmd; ++iter)
      printf("%s\n", chSet[iter]);
    ++setNum;
    scanf("%d", &intCmd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1379 <main+0x239>
movl   $0x0,-0x234(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x238(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1307 <main+0x1c7>
lea    -0x230(%rbp),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1260 <main+0x120>
movslq -0x234(%rbp),%rcx
lea    -0x210(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
mov    %rax,-0x250(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x248(%rbp)
lea    -0x230(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x250(%rbp),%rdi
mov    -0x248(%rbp),%rsi
add    $0x1,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq -0x234(%rbp),%rcx
lea    -0x210(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
mov    %rax,-0x240(%rbp)
lea    -0x230(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x240(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x234(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x234(%rbp)
jmp    12f4 <main+0x1b4>
movslq -0x238(%rbp),%rcx
lea    -0x210(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
mov    %rax,-0x268(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x260(%rbp)
lea    -0x230(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x268(%rbp),%rdi
mov    -0x260(%rbp),%rsi
add    $0x1,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq -0x238(%rbp),%rcx
lea    -0x210(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
mov    %rax,-0x258(%rbp)
lea    -0x230(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x258(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x238(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x238(%rbp)
jmp    12f9 <main+0x1b9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1192 <main+0x52>
mov    -0xc(%rbp),%esi
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1359 <main+0x219>
movslq -0x10(%rbp),%rax
lea    -0x210(%rbp),%rsi
shl    $0x5,%rax
add    %rax,%rsi
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    131f <main+0x1df>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xc97(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
jmp    116b <main+0x2b>
xor    %eax,%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
lea    0xe98(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%r15d
test   %r15d,%r15d
je     12bf <main+0x16f>
mov    $0x1,%ebp
lea    0xe75(%rip),%r12
lea    0x10(%rsp),%r13
jmp    11c4 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
lea    0xe56(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%r15d
test   %r15d,%r15d
je     12bf <main+0x16f>
mov    %ebp,0xc(%rsp)
test   %r15d,%r15d
jle    1270 <main+0x120>
add    $0xffffffff,%r15d
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    1223 <main+0xd3>
nopl   0x0(%rax)
movslq %r15d,%r15
mov    %r15,%rax
shl    $0x5,%rax
lea    (%rsp,%rax,1),%rbx
add    $0x30,%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strncpy@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
movb   $0x0,(%rax,%rbx,1)
add    $0xffffffff,%r15d
add    $0x1,%r14d
cmp    0x8(%rsp),%r14d
jge    1270 <main+0x120>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
test   $0x1,%r14b
jne    11e0 <main+0x90>
movslq %ebp,%rbp
mov    %rbp,%rax
shl    $0x5,%rax
lea    (%rsp,%rax,1),%rbx
add    $0x30,%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strncpy@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
movb   $0x0,(%rax,%rbx,1)
add    $0x1,%ebp
jmp    1218 <main+0xc8>
nop
lea    0xd8f(%rip),%rdi
mov    0xc(%rsp),%ebp
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11a0 <main+0x50>
lea    0x30(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <puts@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x20,%r15
cmp    %rax,%rbx
jl     12a0 <main+0x150>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x238,%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"%s\00"
@.str.2 = [8 x i8] c"SET %d\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [16 x [32 x i8]]
%6 = alloca [32 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %10
10: ; preds = %84, %0
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %88
13: ; preds = %10
store i32 0, i32* %7
%14 = load i32, i32* %2
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %8
store i32 0, i32* %4
br label %16
16: ; preds = %65, %13
%17 = load i32, i32* %4
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %68
20: ; preds = %16
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* %4
%24 = srem i32 %23, 2
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %45
26: ; preds = %20
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [16 x [32 x i8]], [16 x [32 x i8]]* %5, i64 0, i64 %28
%30 = getelementptr inbounds [32 x i8], [32 x i8]* %29, i64 0, i64 0
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%33 = call i64 @strlen(i8* %32)
%34 = add i64 %33, 1
%35 = trunc i64 %34 to i32
%36 = call i32 @strncpy(i8* %30, i8* %31, i32 %35)
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [16 x [32 x i8]], [16 x [32 x i8]]* %5, i64 0, i64 %38
%40 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%41 = call i64 @strlen(i8* %40)
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %39, i64 0, i64 %41
store i8 0, i8* %42
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %64
45: ; preds = %20
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [16 x [32 x i8]], [16 x [32 x i8]]* %5, i64 0, i64 %47
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %48, i64 0, i64 0
%50 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%51 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%52 = call i64 @strlen(i8* %51)
%53 = add i64 %52, 1
%54 = trunc i64 %53 to i32
%55 = call i32 @strncpy(i8* %49, i8* %50, i32 %54)
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [16 x [32 x i8]], [16 x [32 x i8]]* %5, i64 0, i64 %57
%59 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%60 = call i64 @strlen(i8* %59)
%61 = getelementptr inbounds [32 x i8], [32 x i8]* %58, i64 0, i64 %60
store i8 0, i8* %61
%62 = load i32, i32* %8
%63 = add nsw i32 %62, -1
store i32 %63, i32* %8
br label %64
64: ; preds = %45, %26
br label %65
65: ; preds = %64
%66 = load i32, i32* %4
%67 = add nsw i32 %66, 1
store i32 %67, i32* %4
br label %16
68: ; preds = %16
%69 = load i32, i32* %3
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %69)
store i32 0, i32* %4
br label %71
71: ; preds = %81, %68
%72 = load i32, i32* %4
%73 = load i32, i32* %2
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %84
75: ; preds = %71
%76 = load i32, i32* %4
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [16 x [32 x i8]], [16 x [32 x i8]]* %5, i64 0, i64 %77
%79 = getelementptr inbounds [32 x i8], [32 x i8]* %78, i64 0, i64 0
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %79)
br label %81
81: ; preds = %75
%82 = load i32, i32* %4
%83 = add nsw i32 %82, 1
store i32 %83, i32* %4
br label %71
84: ; preds = %71
%85 = load i32, i32* %3
%86 = add nsw i32 %85, 1
store i32 %86, i32* %3
%87 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
88: ; preds = %10
ret i32 0
}

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