#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, char, int, char, int);
int /*<<< orphan*/ scanf(char *, int *, char *, ...);
int main() {
  int N, year, month, day;
  char bk, junk;
  scanf("%d %c", &N, &bk);
  while (N > 0) {
    scanf("%d%c%d%c%d", &year, &junk, &month, &junk, &day);
    if (year / 1000 == 1 || year / 1000 == 2)
      printf("%d%c%.2d%c%.2d\n", year, bk, month, bk, day);
    else {
      if (year < 13)
        printf("%d%c%.2d%c%.2d\n", 2000 + year, bk, month, bk, day);
      else if (year > 12)
        printf("%d%c%.2d%c%.2d\n", 1900 + year, bk, month, bk, day);
    }
    N--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x15(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1243 <main+0x123>
lea    0xeb0(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x16(%rbp),%r8
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r9
mov    %r8,%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
je     1198 <main+0x78>
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x2,%eax
jne    11c0 <main+0xa0>
mov    -0xc(%rbp),%esi
mov    -0x15(%rbp),%dl
mov    -0x10(%rbp),%ecx
mov    -0x15(%rbp),%al
mov    -0x14(%rbp),%r9d
lea    0xe62(%rip),%rdi
movsbl %dl,%edx
movsbl %al,%r8d
call   1030 <printf@plt>
jmp    1235 <main+0x115>
cmpl   $0xd,-0xc(%rbp)
jge    11f8 <main+0xd8>
mov    -0xc(%rbp),%esi
add    $0x7d0,%esi
mov    -0x15(%rbp),%dl
mov    -0x10(%rbp),%ecx
mov    -0x15(%rbp),%al
mov    -0x14(%rbp),%r9d
lea    0xe2a(%rip),%rdi
movsbl %dl,%edx
movsbl %al,%r8d
call   1030 <printf@plt>
jmp    1230 <main+0x110>
cmpl   $0xc,-0xc(%rbp)
jle    122b <main+0x10b>
mov    -0xc(%rbp),%esi
add    $0x76c,%esi
mov    -0x15(%rbp),%dl
mov    -0x10(%rbp),%ecx
mov    -0x15(%rbp),%al
mov    -0x14(%rbp),%r9d
lea    0xdf2(%rip),%rdi
movsbl %dl,%edx
movsbl %al,%r8d
call   1030 <printf@plt>
jmp    1230 <main+0x110>
jmp    1235 <main+0x115>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1145 <main+0x25>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x3(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11e6 <main+0xc6>
lea    0xeae(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x13(%rsp),%rbx
lea    0x4(%rsp),%r13
lea    0xe9e(%rip),%rbp
jmp    11af <main+0x8f>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x76c,%esi
movsbl 0x3(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0x4(%rsp),%r9d
mov    %rbp,%rdi
mov    %edx,%r8d
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0xc(%rsp)
cmp    $0x1,%eax
jle    11e6 <main+0xc6>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %rbx,%r8
mov    %r13,%r9
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%esi
lea    -0x3e8(%rsi),%eax
cmp    $0x7cf,%eax
jbe    1186 <main+0x66>
cmp    $0xc,%esi
jg     1180 <main+0x60>
add    $0x7d0,%esi
jmp    1186 <main+0x66>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %c\00"
@.str.1 = [11 x i8] c"%d%c%d%c%d\00"
@.str.2 = [16 x i8] c"%d%c%.2d%c%.2d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = call i32 (i8*, i32*, i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i8* %5)
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %42
14: ; preds = %0, %38
%15 = call i32 (i8*, i32*, i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %2, i8* %6, i32* %3, i8* %6, i32* %4)
%16 = load i32, i32* %2
%17 = add i32 %16, -1000
%18 = icmp ult i32 %17, 2000
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8, i8* %5
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %16, i8 signext %20, i32 %21, i8 signext %20, i32 %22)
br label %38
24: ; preds = %14
%25 = icmp slt i32 %16, 13
br i1 %25, label %26, label %32
26: ; preds = %24
%27 = add nsw i32 %16, 2000
%28 = load i8, i8* %5
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %27, i8 signext %28, i32 %29, i8 signext %28, i32 %30)
br label %38
32: ; preds = %24
%33 = add nuw nsw i32 %16, 1900
%34 = load i8, i8* %5
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %33, i8 signext %34, i32 %35, i8 signext %34, i32 %36)
br label %38
38: ; preds = %26, %32, %19
%39 = load i32, i32* %1
%40 = add nsw i32 %39, -1
store i32 %40, i32* %1
%41 = icmp sgt i32 %39, 1
br i1 %41, label %14, label %42
42: ; preds = %38, %0
ret i32 0
}