#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 main(void) {
  int t, h, m;
  float d = 0, a = 0, x = 0, ma = 0, ha = 0, y = 0;
  scanf("%d", &t);
  while (t--) {
    h = 0;
    m = 0;
    d = 0;
    ma = 0;
    ha = 0;
    y = 0;
    scanf("%f", &a);
    while (h != 12) {
      if (d > a)
        x = d - a;
      else
        x = a - d;
      if (x < 1.0 / 120.0) {
        if (h < 10 && m < 10)
          printf("0%d:0%d\n", h, m);
        else if (h < 10)
          printf("0%d:%d\n", h, m);
        else if (m < 10)
          printf("%d:0%d\n", h, m);
        else
          printf("%d:%d\n", h, m);
      }
      m++;
      ma += 6;
      ha += 0.5;
      if (ma == 360) {
        h = h + 1;
        ma = 0;
        m = 0;
      }
      if (ha > ma)
        d = ha - ma;
      else
        d = ma - ha;
      y = 360 - d;
      if (y < d)
        d = y;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
lea    0xeb2(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1382 <main+0x262>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
lea    0xe61(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0xc,-0xc(%rbp)
je     137d <main+0x25d>
movss  -0x14(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11f2 <main+0xd2>
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1201 <main+0xe1>
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdee(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12aa <main+0x18a>
cmpl   $0xa,-0xc(%rbp)
jge    1247 <main+0x127>
cmpl   $0xa,-0x10(%rbp)
jge    1247 <main+0x127>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xde1(%rip),%rdi
call   1030 <printf@plt>
jmp    12a5 <main+0x185>
cmpl   $0xa,-0xc(%rbp)
jge    1268 <main+0x148>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdc9(%rip),%rdi
call   1030 <printf@plt>
jmp    12a0 <main+0x180>
cmpl   $0xa,-0x10(%rbp)
jge    1289 <main+0x169>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xda0(%rip),%rdi
call   1030 <printf@plt>
jmp    129b <main+0x17b>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xd92(%rip),%rdi
call   1030 <printf@plt>
jmp    12a0 <main+0x180>
jmp    12a5 <main+0x185>
jmp    12aa <main+0x18a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movss  0xd59(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd32(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
movss  0xd20(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1317 <main+0x1f7>
jp     1317 <main+0x1f7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
movss  -0x24(%rbp),%xmm0
ucomiss -0x20(%rbp),%xmm0
jbe    133a <main+0x21a>
movss  -0x24(%rbp),%xmm0
subss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1349 <main+0x229>
movss  -0x20(%rbp),%xmm0
subss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xcbf(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1378 <main+0x258>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11c5 <main+0xa5>
jmp    1171 <main+0x51>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x8(%rsp)
lea    0xed7(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1161 <main+0x41>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeb2(%rip),%r12
lea    0xeb4(%rip),%r13
lea    0xea5(%rip),%r14
lea    0xea7(%rip),%r15
jmp    1187 <main+0x67>
nop
subl   $0x1,0xc(%rsp)
jb     1150 <main+0x30>
xor    %ebp,%ebp
lea    0xe87(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0xe6c(%rip),%xmm4
xorps  %xmm5,%xmm5
xorps  %xmm6,%xmm6
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    11ef <main+0xcf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movaps %xmm5,%xmm0
subss  %xmm6,%xmm0
movaps %xmm6,%xmm1
subss  %xmm5,%xmm1
movaps %xmm6,%xmm2
cmpltss %xmm5,%xmm2
andps  %xmm2,%xmm0
andnps %xmm1,%xmm2
orps   %xmm0,%xmm2
movaps %xmm4,%xmm0
subss  %xmm2,%xmm0
minss  %xmm2,%xmm0
cmp    $0xc,%ebx
je     1180 <main+0x60>
movss  0x8(%rsp),%xmm1
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
movaps %xmm1,%xmm3
subss  %xmm0,%xmm3
cmpltss %xmm0,%xmm1
andps  %xmm1,%xmm2
andnps %xmm3,%xmm1
orps   %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  0xde0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    126b <main+0x14b>
cmp    $0xa,%ebp
mov    %r13,%rdi
cmovl  %r12,%rdi
mov    %r15,%rax
cmovl  %r14,%rax
cmp    $0xa,%ebx
cmovae %r13,%rdi
cmovae %rax,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
movss  %xmm5,0x14(%rsp)
movss  %xmm6,0x10(%rsp)
call   1030 <printf@plt>
movss  0x10(%rsp),%xmm6
movss  0x14(%rsp),%xmm5
movss  0xda5(%rip),%xmm4
mov    %ebp,%eax
add    $0x1,%eax
addss  0xd90(%rip),%xmm6
addss  0xd8c(%rip),%xmm5
movaps %xmm6,%xmm0
cmpeqss %xmm4,%xmm0
movd   %xmm0,%ecx
sub    %ecx,%ebx
ucomiss %xmm4,%xmm6
mov    $0x0,%ebp
cmovne %eax,%ebp
cmovp  %eax,%ebp
jne    11c0 <main+0xa0>
jp     11c0 <main+0xa0>
xorps  %xmm6,%xmm6
jmp    11c0 <main+0xa0>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [9 x i8] c"0%d:0%d\0A\00"
@.str.3 = [8 x i8] c"0%d:%d\0A\00"
@.str.4 = [8 x i8] c"%d:0%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 float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %8
store float 0.000000e+00, float* %9
store float 0.000000e+00, float* %10
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %12
12: ; preds = %103, %0
%13 = load i32, i32* %2
%14 = add nsw i32 %13, -1
store i32 %14, i32* %2
%15 = icmp ne i32 %13, 0
br i1 %15, label %16, label %104
16: ; preds = %12
store i32 0, i32* %3
store i32 0, i32* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %8
store float 0.000000e+00, float* %9
store float 0.000000e+00, float* %10
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %6)
br label %18
18: ; preds = %102, %16
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 12
br i1 %20, label %21, label %103
21: ; preds = %18
%22 = load float, float* %5
%23 = load float, float* %6
%24 = fcmp ogt float %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load float, float* %5
%27 = load float, float* %6
%28 = fsub float %26, %27
store float %28, float* %7
br label %33
29: ; preds = %21
%30 = load float, float* %6
%31 = load float, float* %5
%32 = fsub float %30, %31
store float %32, float* %7
br label %33
33: ; preds = %29, %25
%34 = load float, float* %7
%35 = fpext float %34 to double
%36 = fcmp olt double %35, 0x3F81111111111111
br i1 %36, label %37, label %68
37: ; preds = %33
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 10
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 10
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i32, i32* %3
%45 = load i32, i32* %4
%46 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %44, i32 %45)
br label %67
47: ; preds = %40, %37
%48 = load i32, i32* %3
%49 = icmp slt i32 %48, 10
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = load i32, i32* %3
%52 = load i32, i32* %4
%53 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %51, i32 %52)
br label %66
54: ; preds = %47
%55 = load i32, i32* %4
%56 = icmp slt i32 %55, 10
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = load i32, i32* %3
%59 = load i32, i32* %4
%60 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %58, i32 %59)
br label %65
61: ; preds = %54
%62 = load i32, i32* %3
%63 = load i32, i32* %4
%64 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %62, i32 %63)
br label %65
65: ; preds = %61, %57
br label %66
66: ; preds = %65, %50
br label %67
67: ; preds = %66, %43
br label %68
68: ; preds = %67, %33
%69 = load i32, i32* %4
%70 = add nsw i32 %69, 1
store i32 %70, i32* %4
%71 = load float, float* %8
%72 = fadd float %71, 6.000000e+00
store float %72, float* %8
%73 = load float, float* %9
%74 = fpext float %73 to double
%75 = fadd double %74, 5.000000e-01
%76 = fptrunc double %75 to float
store float %76, float* %9
%77 = load float, float* %8
%78 = fcmp oeq float %77, 3.600000e+02
br i1 %78, label %79, label %82
79: ; preds = %68
%80 = load i32, i32* %3
%81 = add nsw i32 %80, 1
store i32 %81, i32* %3
store float 0.000000e+00, float* %8
store i32 0, i32* %4
br label %82
82: ; preds = %79, %68
%83 = load float, float* %9
%84 = load float, float* %8
%85 = fcmp ogt float %83, %84
br i1 %85, label %86, label %90
86: ; preds = %82
%87 = load float, float* %9
%88 = load float, float* %8
%89 = fsub float %87, %88
store float %89, float* %5
br label %94
90: ; preds = %82
%91 = load float, float* %8
%92 = load float, float* %9
%93 = fsub float %91, %92
store float %93, float* %5
br label %94
94: ; preds = %90, %86
%95 = load float, float* %5
%96 = fsub float 3.600000e+02, %95
store float %96, float* %10
%97 = load float, float* %10
%98 = load float, float* %5
%99 = fcmp olt float %97, %98
br i1 %99, label %100, label %102
100: ; preds = %94
%101 = load float, float* %10
store float %101, float* %5
br label %102
102: ; preds = %100, %94
br label %18
103: ; preds = %18
br label %12
104: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [9 x i8] c"0%d:0%d\0A\00"
@.str.3 = [8 x i8] c"0%d:%d\0A\00"
@.str.4 = [8 x i8] c"%d:0%d\0A\00"
@.str.5 = [7 x i8] c"%d:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%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 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp eq i32 %6, 0
br i1 %8, label %53, label %13
9: ; preds = %36
%10 = load i32, i32* %1
%11 = add nsw i32 %10, -1
store i32 %11, i32* %1
%12 = icmp eq i32 %10, 0
br i1 %12, label %53, label %13
13: ; preds = %0, %9
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
br label %15
15: ; preds = %13, %36
%16 = phi float [ 0.000000e+00, %13 ], [ %39, %36 ]
%17 = phi float [ 0.000000e+00, %13 ], [ %44, %36 ]
%18 = phi float [ 0.000000e+00, %13 ], [ %51, %36 ]
%19 = phi i32 [ 0, %13 ], [ %43, %36 ]
%20 = phi i32 [ 0, %13 ], [ %42, %36 ]
%21 = load float, float* %2
%22 = fcmp ogt float %18, %21
%23 = fsub float %18, %21
%24 = fsub float %21, %18
%25 = select i1 %22, float %23, float %24
%26 = fpext float %25 to double
%27 = fcmp olt double %26, 0x3F81111111111111
br i1 %27, label %28, label %36
28: ; preds = %15
%29 = icmp ult i32 %20, 10
%30 = icmp slt i32 %19, 10
%31 = select i1 %29, i1 %30, i1 false
%32 = select i1 %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%33 = select i1 %30, 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)
%34 = select i1 %29, i8* %32, i8* %33
%35 = call i32 @printf(i8* %34, i32 %20, i32 %19)
br label %36
36: ; preds = %28, %15
%37 = add nsw i32 %19, 1
%38 = fadd float %17, 6.000000e+00
%39 = fadd float %16, 5.000000e-01
%40 = fcmp oeq float %38, 3.600000e+02
%41 = zext i1 %40 to i32
%42 = add nuw nsw i32 %20, %41
%43 = select i1 %40, i32 0, i32 %37
%44 = select i1 %40, float 0.000000e+00, float %38
%45 = fcmp ogt float %39, %44
%46 = fsub float %39, %44
%47 = fsub float %44, %39
%48 = select i1 %45, float %46, float %47
%49 = fsub float 3.600000e+02, %48
%50 = fcmp olt float %49, %48
%51 = select i1 %50, float %49, float %48
%52 = icmp eq i32 %42, 12
br i1 %52, label %9, label %15
53: ; preds = %9, %0
ret i32 0
}