#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, ...);
char *strtok(char *, char *);
int main(void) {
  char hhmm[10 + 1];
  char *token;
  int numCases, hour, minute, mirrorHour, mirrorMinute;
  scanf("%d", &numCases);
  while (numCases--) {
    scanf("%s", hhmm);
    token = strtok(hhmm, ":");
    mirrorHour = atoi(token);
    token = strtok(NULL, ":");
    mirrorMinute = atoi(token);
    minute = 60 - mirrorMinute;
    hour = 23 - mirrorHour;
    if (minute == 60) {
      hour++;
      minute = 0;
    }
    if (hour > 12) {
      hour -= 12;
    }
    printf("%02d:%02d\n", hour, minute);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     1221 <main+0xe1>
lea    -0xf(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0xf(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe54(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x3c,%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x17,%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x3c,-0x24(%rbp)
jne    11f7 <main+0xb7>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xc,-0x20(%rbp)
jle    120a <main+0xca>
mov    -0x20(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xdf1(%rip),%rdi
call   1030 <printf@plt>
jmp    1161 <main+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,(%rsp)
jb     11e2 <main+0xa2>
lea    0xe99(%rip),%r14
lea    0x5(%rsp),%r15
lea    0xe90(%rip),%rbx
lea    0xe8b(%rip),%r12
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strtok@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    $0x3c,%edx
sub    %eax,%edx
xor    %esi,%esi
test   %eax,%eax
sete   %sil
cmove  %eax,%edx
sub    %ebp,%esi
lea    0x17(%rsi),%eax
add    $0xb,%esi
cmp    $0xd,%eax
cmovl  %eax,%esi
mov    %r12,%rdi
call   1030 <printf@plt>
subl   $0x1,(%rsp)
jae    1180 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
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 = [2 x i8] c":\00"
@.str.3 = [11 x i8] c"%02d:%02d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%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* %4)
br label %10
10: ; preds = %39, %0
%11 = load i32, i32* %4
%12 = add nsw i32 %11, -1
store i32 %12, i32* %4
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %43
14: ; preds = %10
%15 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%18 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %7
%21 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %21, i8** %3
%22 = load i8*, i8** %3
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = sub nsw i32 60, %24
store i32 %25, i32* %6
%26 = load i32, i32* %7
%27 = sub nsw i32 23, %26
store i32 %27, i32* %5
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 60
br i1 %29, label %30, label %33
30: ; preds = %14
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
store i32 0, i32* %6
br label %33
33: ; preds = %30, %14
%34 = load i32, i32* %5
%35 = icmp sgt i32 %34, 12
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %5
%38 = sub nsw i32 %37, 12
store i32 %38, i32* %5
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %41)
br label %10
43: ; 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 = [2 x i8] c":\00"
@.str.3 = [11 x i8] c"%02d:%02d\0A\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = add nsw i32 %6, -1
store i32 %7, i32* %2
%8 = icmp eq i32 %6, 0
br i1 %8, label %27, label %9
9: ; preds = %0, %9
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%11 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @atoi(i8* %11)
%13 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @atoi(i8* %13)
%15 = sub nsw i32 60, %14
%16 = icmp eq i32 %14, 0
%17 = select i1 %16, i32 0, i32 %15
%18 = select i1 %16, i32 24, i32 23
%19 = sub i32 %18, %12
%20 = icmp sgt i32 %19, 12
%21 = add nsw i32 %19, -12
%22 = select i1 %20, i32 %21, i32 %19
%23 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %17)
%24 = load i32, i32* %2
%25 = add nsw i32 %24, -1
store i32 %25, i32* %2
%26 = icmp eq i32 %24, 0
br i1 %26, label %27, label %9
27: ; preds = %9, %0
ret i32 0
}