#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, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int n, i;
  int hour, min, n_hour, n_min;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d:%d", &hour, &min);
    n_min = 60 - min;
    if (hour <= 10) {
      n_hour = 12 - (hour + 1);
    } else if (hour == 12) {
      n_hour = hour - 1;
    } else if (hour == 11) {
      n_hour = hour + 1;
    }
    if (n_min == 60) {
      n_hour = n_hour + 1;
      n_min = 0;
    }
    if (n_hour > 12) {
      n_hour = n_hour - 12;
    }
    if (n_min < 10 && n_hour < 10) {
      printf("0%d:0%d\n", n_hour, n_min);
    } else if (n_min < 10 && n_hour >= 10) {
      printf("%d:0%d\n", n_hour, n_min);
    } else if (n_min >= 10 && n_hour < 10) {
      printf("0%d:%d\n", n_hour, n_min);
    } else {
      printf("%d:%d\n", n_hour, n_min);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     12a6 <main+0x186>
lea    0xea5(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    $0x3c,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x10(%rbp)
jg     1194 <main+0x74>
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
mov    $0xc,%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
jmp    11c9 <main+0xa9>
cmpl   $0xc,-0x10(%rbp)
jne    11ac <main+0x8c>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c4 <main+0xa4>
cmpl   $0xb,-0x10(%rbp)
jne    11bf <main+0x9f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c4 <main+0xa4>
jmp    11c9 <main+0xa9>
cmpl   $0x3c,-0x1c(%rbp)
jne    11e3 <main+0xc3>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xc,-0x18(%rbp)
jle    11f6 <main+0xd6>
mov    -0x18(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    1221 <main+0x101>
cmpl   $0xa,-0x18(%rbp)
jge    1221 <main+0x101>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
jmp    1293 <main+0x173>
cmpl   $0xa,-0x1c(%rbp)
jge    124c <main+0x12c>
cmpl   $0xa,-0x18(%rbp)
jl     124c <main+0x12c>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xdc5(%rip),%rdi
call   1030 <printf@plt>
jmp    128e <main+0x16e>
cmpl   $0xa,-0x1c(%rbp)
jl     1277 <main+0x157>
cmpl   $0xa,-0x18(%rbp)
jge    1277 <main+0x157>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xda2(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xd8c(%rip),%rdi
call   1030 <printf@plt>
jmp    128e <main+0x16e>
jmp    1293 <main+0x173>
jmp    1298 <main+0x178>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1148 <main+0x28>
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    0xece(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1236 <main+0x116>
lea    0xead(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xea2(%rip),%r13
xor    %ebp,%ebp
jmp    11a3 <main+0x83>
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%ebx
lea    0xe96(%rip),%rcx
mov    %rcx,%rdi
lea    0xe8b(%rip),%rax
cmovl  %rax,%rdi
cmp    $0xa,%edx
cmovl  %rcx,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    1236 <main+0x116>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
mov    $0x3c,%edx
sub    %eax,%edx
mov    0x14(%rsp),%ecx
cmp    $0xa,%ecx
jg     11d0 <main+0xb0>
mov    $0xb,%ebx
sub    %ecx,%ebx
jmp    11f0 <main+0xd0>
cmp    $0xc,%ecx
je     11e1 <main+0xc1>
cmp    $0xb,%ecx
jne    11f0 <main+0xd0>
mov    $0xc,%ebx
jmp    11f0 <main+0xd0>
mov    $0xb,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
cmove  %eax,%edx
lea    (%rbx,%rcx,1),%eax
cmp    $0xd,%eax
lea    -0xc(%rbx,%rcx,1),%ebx
cmovl  %eax,%ebx
cmp    $0x9,%edx
jg     1218 <main+0xf8>
mov    %r13,%rdi
cmp    $0xa,%ebx
jl     118f <main+0x6f>
cmp    $0x9,%edx
jg     1170 <main+0x50>
lea    0xddf(%rip),%rdi
cmp    $0x9,%ebx
jg     118f <main+0x6f>
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x18,%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 = [6 x i8] c"%d:%d\00"
@.str.2 = [9 x i8] c"0%d:0%d\0A\00"
@.str.3 = [8 x i8] c"%d:0%d\0A\00"
@.str.4 = [8 x i8] c"0%d:%d\0A\00"
@.str.5 = [7 x i8] c"%d:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %9
9: ; preds = %86, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %89
13: ; preds = %9
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%15 = load i32, i32* %5
%16 = sub nsw i32 60, %15
store i32 %16, i32* %7
%17 = load i32, i32* %4
%18 = icmp sle i32 %17, 10
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
%22 = sub nsw i32 12, %21
store i32 %22, i32* %6
br label %37
23: ; preds = %13
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 12
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
store i32 %28, i32* %6
br label %36
29: ; preds = %23
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 11
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %35
35: ; preds = %32, %29
br label %36
36: ; preds = %35, %26
br label %37
37: ; preds = %36, %19
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 60
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
store i32 0, i32* %7
br label %43
43: ; preds = %40, %37
%44 = load i32, i32* %6
%45 = icmp sgt i32 %44, 12
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %6
%48 = sub nsw i32 %47, 12
store i32 %48, i32* %6
br label %49
49: ; preds = %46, %43
%50 = load i32, i32* %7
%51 = icmp slt i32 %50, 10
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load i32, i32* %6
%54 = icmp slt i32 %53, 10
br i1 %54, label %55, label %59
55: ; preds = %52
%56 = load i32, i32* %6
%57 = load i32, i32* %7
%58 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %56, i32 %57)
br label %85
59: ; preds = %52, %49
%60 = load i32, i32* %7
%61 = icmp slt i32 %60, 10
br i1 %61, label %62, label %69
62: ; preds = %59
%63 = load i32, i32* %6
%64 = icmp sge i32 %63, 10
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = load i32, i32* %6
%67 = load i32, i32* %7
%68 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %66, i32 %67)
br label %84
69: ; preds = %62, %59
%70 = load i32, i32* %7
%71 = icmp sge i32 %70, 10
br i1 %71, label %72, label %79
72: ; preds = %69
%73 = load i32, i32* %6
%74 = icmp slt i32 %73, 10
br i1 %74, label %75, label %79
75: ; preds = %72
%76 = load i32, i32* %6
%77 = load i32, i32* %7
%78 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %76, i32 %77)
br label %83
79: ; preds = %72, %69
%80 = load i32, i32* %6
%81 = load i32, i32* %7
%82 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %80, i32 %81)
br label %83
83: ; preds = %79, %75
br label %84
84: ; preds = %83, %65
br label %85
85: ; preds = %84, %55
br label %86
86: ; preds = %85
%87 = load i32, i32* %3
%88 = add nsw i32 %87, 1
store i32 %88, i32* %3
br label %9
89: ; preds = %9
ret i32 0
}

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