Read problems statements in Mandarin Chinese  and Russian  

Chef is sitting in a very boring lecture, waiting for it to end. He has recently asked his friend about the time, and instead of the straightforward answer, his friend, being an absolute jerk, told him the absolute value of angle between hour and minute hands.

But that is obviously not what he wanted to know, so he asks you to help him, by writing down all valid values of time (in hours and minutes, both non-negative integers) from midnight (inclusive) to noon (not inclusive) which satisfy the information Chef's friend has provided. Keep in mind that a time value is considered valid if the angle between the clock's hands for that value and the angle Chef's friend has described differ by less than 1/120 degrees.

Note that the movement of the minute hand influences the hour hand. That is, every minute, it moves by 1/60^{th} of the angular distance between two consecutive hour marks.

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases. 

The only line of each test case contain a single real number A in decimal notation, denoting the angle between minute and hour hands. The fractional part won't contain more than 4 digits.

------ Output ------ 

For each test case print all valid values of time as described in the statement in the format "hh:mm" (without quotes), where hh means number of hours, and mm the number of minutes. Times should be printed in chronological order.

------ 
------ Constraints -----

$1 ≤ T ≤ 10^{5}$
$0 ≤ A ≤ 180$
$Output won't exceed 1 MB.$

Subtask 1: (30 points)
$A is an integer from the set {0, 90, 180}.$

Subtask 2: (30 points)
$A is an integer.$

Subtask 3: (40 points)
$No additional constraints.$

----- Sample Input 1 ------ 
2
0
30
----- Sample Output 1 ------ 
00:00
01:00
11:00

Difficulty: MEDIUM_HARD

Solutions:
__author__ = 'Om Kumar Sahoo'
arr = [[] for x in range(361)]
count = 0
for i in range(12):
	for j in range(60):
		temp = abs(j * 12 - count)
		if temp > 360:
			temp = 720 - temp
		arr[temp].append([i, j])
		count += 1
cas = int(input())
for i in range(cas):
	a = 2 * float(input())
	rounda = int((a * 10 + 5) / 10)
	if abs(a - rounda) < 1 / 60:
		for x in arr[rounda]:
			print('%02d:%02d' % (x[0], x[1]))


import math
a = [0] * 721
for i in range(1, 720):
	a[i] = a[i - 1] + 5.5
for i in range(1, 720):
	a[i] = a[i] % 360
	if a[i] > 180:
		a[i] = 360 - a[i]
t = int(input())
for i in range(0, t):
	n = float(input())
	q = n + 1 / 120
	p = n - 1 / 120
	d = math.floor(q)
	c = d + 0.5
	if p > d and q < c:
		continue
	if p > c:
		continue
	for j in range(0, 720):
		if a[j] < q and a[j] > p:
			x = j // 60
			y = j % 60
			x = str(x)
			y = str(y)
			if len(x) == 1:
				x = '0' + x
			if len(y) == 1:
				y = '0' + y
			print(x, end=':')
			print(y)
			if j != 0 and j != 360:
				k = 720 - j
				x = k // 60
				y = k % 60
				x = str(x)
				y = str(y)
				if len(x) == 1:
					x = '0' + x
				if len(y) == 1:
					y = '0' + y
				print(x, end=':')
				print(y)
			break


import sys
t = int(sys.stdin.readline())
list = ['00:00', '02:11', '09:49', '04:22', '07:38', '05:27', '06:33', '03:16', '08:44', '01:05', '10:55', '01:06', '10:54', '03:17', '08:43', '05:28', '06:32', '04:21', '07:39', '02:10', '09:50', '00:01', '11:59', '02:12', '09:48', '04:23', '07:37', '05:26', '06:34', '03:15', '08:45', '01:04', '10:56', '01:07', '10:53', '03:18', '08:42', '05:29', '06:31', '04:20', '07:40', '02:09', '09:51', '00:02', '11:58', '02:13', '09:47', '04:24', '07:36', '05:25', '06:35', '03:14', '08:46', '01:03', '10:57', '01:08', '10:52', '03:19', '08:41', '05:30', '06:30', '04:19', '07:41', '02:08', '09:52', '00:03', '11:57', '02:14', '09:46', '04:25', '07:35', '05:24', '06:36', '03:13', '08:47', '01:02', '10:58', '01:09', '10:51', '03:20', '08:40', '05:31', '06:29', '04:18', '07:42', '02:07', '09:53', '00:04', '11:56', '02:15', '09:45', '04:26', '07:34', '05:23', '06:37', '03:12', '08:48', '01:01', '10:59', '01:10', '10:50', '03:21', '08:39', '05:32', '06:28', '04:17', '07:43', '02:06', '09:54', '00:05', '11:55', '02:16', '09:44', '04:27', '07:33', '05:22', '06:38', '03:11', '08:49', '01:00', '11:00', '01:11', '10:49', '03:22', '08:38', '05:33', '06:27', '04:16', '07:44', '02:05', '09:55', '00:06', '11:54', '02:17', '09:43', '04:28', '07:32', '05:21', '06:39', '03:10', '08:50', '00:59', '11:01', '01:12', '10:48', '03:23', '08:37', '05:34', '06:26', '04:15', '07:45', '02:04', '09:56', '00:07', '11:53', '02:18', '09:42', '04:29', '07:31', '05:20', '06:40', '03:09', '08:51', '00:58', '11:02', '01:13', '10:47', '03:24', '08:36', '05:35', '06:25', '04:14', '07:46', '02:03', '09:57', '00:08', '11:52', '02:19', '09:41', '04:30', '07:30', '05:19', '06:41', '03:08', '08:52', '00:57', '11:03', '01:14', '10:46', '03:25', '08:35', '05:36', '06:24', '04:13', '07:47', '02:02', '09:58', '00:09', '11:51', '02:20', '09:40', '04:31', '07:29', '05:18', '06:42', '03:07', '08:53', '00:56', '11:04', '01:15', '10:45', '03:26', '08:34', '05:37', '06:23', '04:12', '07:48', '02:01', '09:59', '00:10', '11:50', '02:21', '09:39', '04:32', '07:28', '05:17', '06:43', '03:06', '08:54', '00:55', '11:05', '01:16', '10:44', '03:27', '08:33', '05:38', '06:22', '04:11', '07:49', '02:00', '10:00', '00:11', '11:49', '02:22', '09:38', '04:33', '07:27', '05:16', '06:44', '03:05', '08:55', '00:54', '11:06', '01:17', '10:43', '03:28', '08:32', '05:39', '06:21', '04:10', '07:50', '01:59', '10:01', '00:12', '11:48', '02:23', '09:37', '04:34', '07:26', '05:15', '06:45', '03:04', '08:56', '00:53', '11:07', '01:18', '10:42', '03:29', '08:31', '05:40', '06:20', '04:09', '07:51', '01:58', '10:02', '00:13', '11:47', '02:24', '09:36', '04:35', '07:25', '05:14', '06:46', '03:03', '08:57', '00:52', '11:08', '01:19', '10:41', '03:30', '08:30', '05:41', '06:19', '04:08', '07:52', '01:57', '10:03', '00:14', '11:46', '02:25', '09:35', '04:36', '07:24', '05:13', '06:47', '03:02', '08:58', '00:51', '11:09', '01:20', '10:40', '03:31', '08:29', '05:42', '06:18', '04:07', '07:53', '01:56', '10:04', '00:15', '11:45', '02:26', '09:34', '04:37', '07:23', '05:12', '06:48', '03:01', '08:59', '00:50', '11:10', '01:21', '10:39', '03:32', '08:28', '05:43', '06:17', '04:06', '07:54', '01:55', '10:05', '00:16', '11:44', '02:27', '09:33', '04:38', '07:22', '05:11', '06:49', '03:00', '09:00', '00:49', '11:11', '01:22', '10:38', '03:33', '08:27', '05:44', '06:16', '04:05', '07:55', '01:54', '10:06', '00:17', '11:43', '02:28', '09:32', '04:39', '07:21', '05:10', '06:50', '02:59', '09:01', '00:48', '11:12', '01:23', '10:37', '03:34', '08:26', '05:45', '06:15', '04:04', '07:56', '01:53', '10:07', '00:18', '11:42', '02:29', '09:31', '04:40', '07:20', '05:09', '06:51', '02:58', '09:02', '00:47', '11:13', '01:24', '10:36', '03:35', '08:25', '05:46', '06:14', '04:03', '07:57', '01:52', '10:08', '00:19', '11:41', '02:30', '09:30', '04:41', '07:19', '05:08', '06:52', '02:57', '09:03', '00:46', '11:14', '01:25', '10:35', '03:36', '08:24', '05:47', '06:13', '04:02', '07:58', '01:51', '10:09', '00:20', '11:40', '02:31', '09:29', '04:42', '07:18', '05:07', '06:53', '02:56', '09:04', '00:45', '11:15', '01:26', '10:34', '03:37', '08:23', '05:48', '06:12', '04:01', '07:59', '01:50', '10:10', '00:21', '11:39', '02:32', '09:28', '04:43', '07:17', '05:06', '06:54', '02:55', '09:05', '00:44', '11:16', '01:27', '10:33', '03:38', '08:22', '05:49', '06:11', '04:00', '08:00', '01:49', '10:11', '00:22', '11:38', '02:33', '09:27', '04:44', '07:16', '05:05', '06:55', '02:54', '09:06', '00:43', '11:17', '01:28', '10:32', '03:39', '08:21', '05:50', '06:10', '03:59', '08:01', '01:48', '10:12', '00:23', '11:37', '02:34', '09:26', '04:45', '07:15', '05:04', '06:56', '02:53', '09:07', '00:42', '11:18', '01:29', '10:31', '03:40', '08:20', '05:51', '06:09', '03:58', '08:02', '01:47', '10:13', '00:24', '11:36', '02:35', '09:25', '04:46', '07:14', '05:03', '06:57', '02:52', '09:08', '00:41', '11:19', '01:30', '10:30', '03:41', '08:19', '05:52', '06:08', '03:57', '08:03', '01:46', '10:14', '00:25', '11:35', '02:36', '09:24', '04:47', '07:13', '05:02', '06:58', '02:51', '09:09', '00:40', '11:20', '01:31', '10:29', '03:42', '08:18', '05:53', '06:07', '03:56', '08:04', '01:45', '10:15', '00:26', '11:34', '02:37', '09:23', '04:48', '07:12', '05:01', '06:59', '02:50', '09:10', '00:39', '11:21', '01:32', '10:28', '03:43', '08:17', '05:54', '06:06', '03:55', '08:05', '01:44', '10:16', '00:27', '11:33', '02:38', '09:22', '04:49', '07:11', '05:00', '07:00', '02:49', '09:11', '00:38', '11:22', '01:33', '10:27', '03:44', '08:16', '05:55', '06:05', '03:54', '08:06', '01:43', '10:17', '00:28', '11:32', '02:39', '09:21', '04:50', '07:10', '04:59', '07:01', '02:48', '09:12', '00:37', '11:23', '01:34', '10:26', '03:45', '08:15', '05:56', '06:04', '03:53', '08:07', '01:42', '10:18', '00:29', '11:31', '02:40', '09:20', '04:51', '07:09', '04:58', '07:02', '02:47', '09:13', '00:36', '11:24', '01:35', '10:25', '03:46', '08:14', '05:57', '06:03', '03:52', '08:08', '01:41', '10:19', '00:30', '11:30', '02:41', '09:19', '04:52', '07:08', '04:57', '07:03', '02:46', '09:14', '00:35', '11:25', '01:36', '10:24', '03:47', '08:13', '05:58', '06:02', '03:51', '08:09', '01:40', '10:20', '00:31', '11:29', '02:42', '09:18', '04:53', '07:07', '04:56', '07:04', '02:45', '09:15', '00:34', '11:26', '01:37', '10:23', '03:48', '08:12', '05:59', '06:01', '03:50', '08:10', '01:39', '10:21', '00:32', '11:28', '02:43', '09:17', '04:54', '07:06', '04:55', '07:05', '02:44', '09:16', '00:33', '11:27', '01:38', '10:22', '03:49', '08:11', '06:00']
for i in range(t):
	a = float(sys.stdin.readline())
	n = int(a / 1)
	if n <= a < n + 1 / 120:
		a = n
	elif n + 0.5 - 1 / 120 < a < n + 0.5 + 1 / 120:
		a = n + 0.5
	elif n + 1 - 1 / 120 < a < n + 1:
		a = n + 1
	else:
		a = 500
	if a < 0.5:
		print('00:00')
	elif a == 180.0:
		print('06:00')
	elif a == 500:
		continue
	else:
		print(list[int(a * 4 - 1)])
		print(list[int(a * 4)])


angles = []
for t in range(0, 720):
	angle = abs(6 * t % 360 - t / 2)
	if angle > 180:
		angle = abs(angle - 360)
	angles.append((t, angle))
angles.sort(key=lambda i: i[1])
times = [i[0] for i in angles]
angles = [i[1] for i in angles]
from bisect import bisect_left
from datetime import time
for t in range(int(input())):
	angle = float(input())
	p = bisect_left(angles, angle - 1 / 120)
	solutions = []
	while p < 720 and abs(angle - angles[p]) < 1 / 120:
		solutions.append(times[p])
		p += 1
	for s in solutions:
		print(time(s // 60, s % 60).isoformat()[:5])


__author__ = 'aadityataparia'

def timedl():
	timel = {}
	for HH in range(12):
		for MM in range(60):
			angl = abs(HH * 30 - MM * 11 / 2)
			if angl > 180:
				angl = (360 - angl) * 120
			else:
				angl *= 120
			if timel.get(angl) is None:
				timel[angl] = []
			if HH < 10 and MM < 10:
				timel[angl].append('0' + str(HH) + ':' + '0' + str(MM))
			elif MM >= 10 > HH:
				timel[angl].append('0' + str(HH) + ':' + str(MM))
			elif HH >= 10 > MM:
				timel[angl].append(str(HH) + ':' + '0' + str(MM))
			else:
				timel[angl].append(str(HH) + ':' + str(MM))
	return timel
Ttime = timedl()
for k in range(int(input())):
	ang = int(float(input()) * 120)
	if Ttime.get(ang) is not None:
		[print(item) for item in sorted(Ttime[ang])]
	if Ttime.get(ang + 1) is not None:
		[print(item) for item in sorted(Ttime[ang + 1])]


di = {}
error = round(1 / 120.0, 4)
for hh in range(12):
	for mm in range(60):
		h = 30 * hh + mm / 2.0
		m = mm * 6.0
		angle = abs(h - m)
		angle = min(angle, 360 - angle)
		angle = round(angle, 4)
		if angle in di:
			di[angle] += [(hh, mm)]
		else:
			di[angle] = [(hh, mm)]
T = int(input())
angles = list(di.keys())
angles.sort()
while T:
	A = float(input())
	a1 = A + error
	a2 = A - error
	for a in angles:
		if a > a1:
			break
		elif a >= a2 and a <= a1:
			for hm in di[a]:
				print('%02d:%02d' % hm)
	T -= 1


def printer(hr, mi):
	if hr // 10 == 0 and mi // 10 == 0:
		return '0' + str(hr) + ':0' + str(mi)
	elif mi // 10 == 0:
		return str(hr) + ':0' + str(mi)
	elif hr // 10 == 0:
		return '0' + str(hr) + ':' + str(mi)
	else:
		return str(hr) + ':' + str(mi)

def save():
	di = {}
	di[180] = ['06:00']
	for hr in range(6):
		for mi in range(60):
			ang_min = mi * 6
			ang_hr = (hr * 60 + mi) * 0.5
			diff = abs(ang_min - ang_hr)
			diff = min(diff, 360 - diff)
			di[diff] = [printer(hr, mi)]
			if diff != 0:
				if mi != 0:
					di[diff].append(printer(11 - hr, 60 - mi))
				else:
					di[diff].append(printer(12 - hr, mi))
	return di

def round(n):
	te = int(n * 10)
	if te % 10 == 5 or te % 10 == 0:
		te = te / 10
	elif te % 10 == 9 or te % 10 == 4:
		te = (te + 1) / 10
	if abs(te - n) <= 1 / 120:
		return te
	else:
		return -1
t = int(input())
di = save()
while t:
	t -= 1
	n = float(input())
	n = round(n)
	if n != -1:
		print(di[n][0])
		if n != 0 and n != 180:
			print(di[n][1])


def calculate_angle(h, m):
	x = abs(0.5 * (60 * h - 11 * m))
	return min(x, 360 - x)

def formated_time(hour, minute):
	if hour < 10:
		hour = '0' + str(hour)
	else:
		hour = str(hour)
	if minute < 10:
		minute = '0' + str(minute)
	else:
		minute = str(minute)
	return ':'.join([hour, minute])

def create_dict():
	d = dict()
	for hour in range(12):
		for minute in range(60):
			angle = calculate_angle(hour, minute)
			if angle in d:
				d[angle].append(formated_time(hour, minute))
			else:
				d[angle] = [formated_time(hour, minute)]
	return d

def solve(target_angle, d):
	value1 = target_angle - 1 / 120
	value2 = target_angle + 1 / 120
	for (key, value) in d.items():
		if value1 < key < value2:
			print('\n'.join(value))
			break
d = create_dict()
t = int(input())
for i in range(t):
	target_angle = float(input())
	solve(target_angle, d)


import math
D = {0.0: ['00:00'], 5.5: ['00:01', '11:59'], 2.0: ['03:16', '08:44'], 127.5: ['04:45', '07:15'], 4.0: ['05:28', '06:32'], 5.0: ['02:10', '09:50'], 49.5: ['00:09', '11:51'], 1.0: ['04:22', '07:38'], 8.0: ['01:04', '10:56'], 9.0: ['03:18', '08:42'], 10.0: ['04:20', '07:40'], 11.0: ['00:02', '11:58'], 12.0: ['04:24', '07:36'], 13.0: ['03:14', '08:46'], 14.0: ['01:08', '10:52'], 15.0: ['05:30', '06:30'], 16.0: ['02:08', '09:52'], 17.0: ['02:14', '09:46'], 18.0: ['05:24', '06:36'], 19.0: ['01:02', '10:58'], 20.0: ['03:20', '08:40'], 21.0: ['04:18', '07:42'], 22.0: ['00:04', '11:56'], 23.0: ['04:26', '07:34'], 24.0: ['03:12', '08:48'], 25.0: ['01:10', '10:50'], 26.0: ['05:32', '06:28'], 27.0: ['02:06', '09:54'], 28.0: ['02:16', '09:44'], 29.0: ['05:22', '06:38'], 30.0: ['01:00', '11:00'], 0.5: ['02:11', '09:49'], 32.0: ['04:16', '07:44'], 33.0: ['00:06', '11:54'], 34.0: ['04:28', '07:32'], 35.0: ['03:10', '08:50'], 178.5: ['00:33', '11:27'], 6.0: ['02:12', '09:48'], 38.0: ['02:04', '09:56'], 39.0: ['02:18', '09:42'], 40.0: ['05:20', '06:40'], 41.0: ['00:58', '11:02'], 42.0: ['03:24', '08:36'], 43.0: ['04:14', '07:46'], 44.0: ['00:08', '11:52'], 45.0: ['04:30', '07:30'], 46.0: ['03:08', '08:52'], 47.0: ['01:14', '10:46'], 48.0: ['05:36', '06:24'], 49.0: ['02:02', '09:58'], 50.0: ['02:20', '09:40'], 51.0: ['05:18', '06:42'], 52.0: ['00:56', '11:04'], 53.0: ['03:26', '08:34'], 54.0: ['04:12', '07:48'], 55.0: ['00:10', '11:50'], 56.0: ['04:32', '07:28'], 57.0: ['03:06', '08:54'], 58.0: ['01:16', '10:44'], 59.0: ['05:38', '06:22'], 60.0: ['02:00', '10:00'], 61.0: ['02:22', '09:38'], 62.0: ['05:16', '06:44'], 63.0: ['00:54', '11:06'], 64.0: ['03:28', '08:32'], 65.0: ['04:10', '07:50'], 66.0: ['00:12', '11:48'], 67.0: ['04:34', '07:26'], 68.0: ['03:04', '08:56'], 69.0: ['01:18', '10:42'], 70.0: ['05:40', '06:20'], 71.0: ['01:58', '10:02'], 72.0: ['02:24', '09:36'], 73.0: ['05:14', '06:46'], 74.0: ['00:52', '11:08'], 75.0: ['03:30', '08:30'], 76.0: ['04:08', '07:52'], 77.0: ['00:14', '11:46'], 78.0: ['04:36', '07:24'], 79.0: ['03:02', '08:58'], 80.0: ['01:20', '10:40'], 81.0: ['05:42', '06:18'], 82.0: ['01:56', '10:04'], 83.0: ['02:26', '09:34'], 84.0: ['05:12', '06:48'], 85.0: ['00:50', '11:10'], 86.0: ['03:32', '08:28'], 87.0: ['04:06', '07:54'], 88.0: ['00:16', '11:44'], 89.0: ['04:38', '07:22'], 90.0: ['03:00', '09:00'], 91.0: ['01:22', '10:38'], 92.0: ['05:44', '06:16'], 93.0: ['01:54', '10:06'], 94.0: ['02:28', '09:32'], 2.5: ['01:05', '10:55'], 96.0: ['00:48', '11:12'], 97.0: ['03:34', '08:26'], 98.0: ['04:04', '07:56'], 99.0: ['00:18', '11:42'], 100.0: ['04:40', '07:20'], 101.0: ['02:58', '09:02'], 102.0: ['01:24', '10:36'], 103.0: ['05:46', '06:14'], 69.5: ['03:29', '08:31'], 105.0: ['02:30', '09:30'], 106.0: ['05:08', '06:52'], 107.0: ['00:46', '11:14'], 108.0: ['03:36', '08:24'], 109.0: ['04:02', '07:58'], 110.0: ['00:20', '11:40'], 111.0: ['04:42', '07:18'], 112.0: ['02:56', '09:04'], 113.0: ['01:26', '10:34'], 114.0: ['05:48', '06:12'], 115.0: ['01:50', '10:10'], 116.0: ['02:32', '09:28'], 117.0: ['05:06', '06:54'], 118.0: ['00:44', '11:16'], 119.0: ['03:38', '08:22'], 120.0: ['04:00', '08:00'], 121.0: ['00:22', '11:38'], 122.0: ['04:44', '07:16'], 123.0: ['02:54', '09:06'], 124.0: ['01:28', '10:32'], 125.0: ['05:50', '06:10'], 126.0: ['01:48', '10:12'], 127.0: ['02:34', '09:26'], 128.0: ['05:04', '06:56'], 129.0: ['00:42', '11:18'], 130.0: ['03:40', '08:20'], 131.0: ['03:58', '08:02'], 132.0: ['00:24', '11:36'], 133.0: ['04:46', '07:14'], 134.0: ['02:52', '09:08'], 135.0: ['01:30', '10:30'], 136.0: ['05:52', '06:08'], 137.0: ['01:46', '10:14'], 138.0: ['02:36', '09:24'], 139.0: ['05:02', '06:58'], 140.0: ['00:40', '11:20'], 141.0: ['03:42', '08:18'], 142.0: ['03:56', '08:04'], 143.0: ['00:26', '11:34'], 144.0: ['04:48', '07:12'], 145.0: ['02:50', '09:10'], 146.0: ['01:32', '10:28'], 147.0: ['05:54', '06:06'], 148.0: ['01:44', '10:16'], 149.0: ['02:38', '09:22'], 150.0: ['05:00', '07:00'], 151.0: ['00:38', '11:22'], 152.0: ['03:44', '08:16'], 153.0: ['03:54', '08:06'], 154.0: ['00:28', '11:32'], 37.5: ['04:15', '07:45'], 156.0: ['02:48', '09:12'], 157.0: ['01:34', '10:26'], 158.0: ['05:56', '06:04'], 13.5: ['01:03', '10:57'], 160.0: ['02:40', '09:20'], 161.0: ['04:58', '07:02'], 162.0: ['00:36', '11:24'], 163.0: ['03:46', '08:14'], 164.0: ['03:52', '08:08'], 165.0: ['00:30', '11:30'], 166.0: ['04:52', '07:08'], 167.0: ['02:46', '09:14'], 168.0: ['01:36', '10:24'], 33.5: ['02:17', '09:43'], 170.0: ['01:40', '10:20'], 171.0: ['02:42', '09:18'], 172.0: ['04:56', '07:04'], 173.0: ['00:34', '11:26'], 174.0: ['03:48', '08:12'], 175.0: ['03:50', '08:10'], 176.0: ['00:32', '11:28'], 177.0: ['04:54', '07:06'], 178.0: ['02:44', '09:16'], 179.0: ['01:38', '10:22'], 180.0: ['06:00'], 31.0: ['03:22', '08:38'], 161.5: ['02:47', '09:13'], 137.5: ['00:25', '11:35'], 7.0: ['05:26', '06:34'], 36.0: ['01:12', '10:48'], 39.5: ['04:29', '07:31'], 50.5: ['04:31', '07:29'], 24.5: ['01:01', '10:59'], 77.5: ['02:25', '09:35'], 134.5: ['00:41', '11:19'], 21.5: ['02:07', '09:53'], 169.5: ['03:51', '08:09'], 112.5: ['00:45', '11:15'], 41.5: ['01:13', '10:47'], 156.5: ['00:37', '11:23'], 147.5: ['03:55', '08:05'], 25.5: ['03:21', '08:39'], 81.5: ['04:07', '07:53'], 142.5: ['01:45', '10:15'], 177.5: ['04:55', '07:05'], 116.5: ['04:43', '07:17'], 43.5: ['02:03', '09:57'], 26.5: ['04:17', '07:43'], 85.5: ['01:21', '10:39'], 150.5: ['02:49', '09:11'], 120.5: ['01:49', '10:11'], 35.5: ['00:59', '11:01'], 45.5: ['05:19', '06:41'], 27.5: ['00:05', '11:55'], 89.5: ['05:11', '06:49'], 158.5: ['03:53', '08:07'], 131.5: ['01:47', '10:13'], 124.5: ['03:39', '08:21'], 47.5: ['03:25', '08:35'], 3.5: ['03:17', '08:43'], 3.0: ['01:06', '10:54'], 28.5: ['04:27', '07:33'], 100.5: ['05:09', '06:51'], 96.5: ['01:23', '10:37'], 139.5: ['02:51', '09:09'], 140.5: ['01:31', '10:29'], 29.5: ['03:11', '08:49'], 97.5: ['05:45', '06:15'], 174.5: ['05:59', '06:01'], 66.5: ['02:23', '09:37'], 95.0: ['05:10', '06:50'], 51.5: ['03:07', '08:53'], 57.5: ['00:55', '11:05'], 30.5: ['01:11', '10:49'], 101.5: ['00:47', '11:13'], 104.0: ['01:52', '10:08'], 70.5: ['04:09', '07:51'], 155.5: ['04:59', '07:01'], 53.5: ['05:37', '06:23'], 31.5: ['05:33', '06:27'], 105.5: ['04:41', '07:19'], 153.5: ['01:43', '10:17'], 74.5: ['01:19', '10:41'], 163.5: ['05:57', '06:03'], 55.5: ['02:21', '09:39'], 109.5: ['01:51', '10:09'], 78.5: ['05:13', '06:47'], 136.5: ['03:57', '08:03'], 171.5: ['04:53', '07:07'], 10.5: ['02:09', '09:51'], 157.5: ['03:45', '08:15'], 113.5: ['03:37', '08:23'], 82.5: ['00:15', '11:45'], 144.5: ['05:01', '06:59'], 172.5: ['02:45', '09:15'], 179.5: ['03:49', '08:11'], 59.5: ['04:11', '07:49'], 117.5: ['02:55', '09:05'], 73.5: ['03:03', '08:57'], 23.5: ['05:23', '06:37'], 86.5: ['05:43', '06:17'], 152.5: ['05:55', '06:05'], 133.5: ['05:03', '06:57'], 61.5: ['04:33', '07:27'], 155.0: ['04:50', '07:10'], 121.5: ['02:33', '09:27'], 90.5: ['00:49', '11:11'], 160.5: ['04:51', '07:09'], 159.0: ['01:42', '10:18'], 22.5: ['02:15', '09:45'], 63.5: ['01:17', '10:43'], 8.5: ['01:07', '10:53'], 125.5: ['03:59', '08:01'], 169.0: ['05:58', '06:02'], 94.5: ['04:39', '07:21'], 168.5: ['03:47', '08:13'], 32.5: ['02:05', '09:55'], 65.5: ['01:59', '10:01'], 104.5: ['00:19', '11:41'], 141.5: ['05:53', '06:07'], 166.5: ['04:57', '07:03'], 98.5: ['01:53', '10:07'], 176.5: ['02:43', '09:17'], 34.5: ['05:21', '06:39'], 1.5: ['05:27', '06:33'], 67.5: ['05:15', '06:45'], 37.0: ['05:34', '06:26'], 149.5: ['04:49', '07:11'], 108.5: ['05:47', '06:13'], 102.5: ['03:35', '08:25'], 36.5: ['03:23', '08:37'], 4.5: ['04:21', '07:39'], 71.5: ['00:13', '11:47'], 106.5: ['02:57', '09:03'], 38.5: ['00:07', '11:53'], 19.5: ['01:09', '10:51'], 75.5: ['05:41', '06:19'], 130.5: ['05:51', '06:09'], 165.5: ['02:41', '09:19'], 110.5: ['02:31', '09:29'], 40.5: ['03:09', '08:51'], 93.5: ['00:17', '11:43'], 79.5: ['00:51', '11:09'], 138.5: ['04:47', '07:13'], 173.5: ['01:37', '10:23'], 159.5: ['00:29', '11:31'], 114.5: ['04:01', '07:59'], 42.5: ['05:35', '06:25'], 83.5: ['04:37', '07:23'], 146.5: ['03:43', '08:17'], 11.5: ['02:13', '09:47'], 118.5: ['01:27', '10:33'], 44.5: ['02:19', '09:41'], 87.5: ['01:55', '10:05'], 154.5: ['02:39', '09:21'], 46.5: ['00:57', '11:03'], 91.5: ['03:33', '08:27'], 162.5: ['01:35', '10:25'], 12.5: ['05:25', '06:35'], 135.5: ['03:41', '08:19'], 126.5: ['00:23', '11:37'], 122.5: ['05:05', '06:55'], 95.5: ['02:59', '09:01'], 170.5: ['00:31', '11:29'], 9.5: ['05:29', '06:31'], 64.5: ['05:39', '06:21'], 128.5: ['02:53', '09:07'], 143.5: ['02:37', '09:23'], 99.5: ['02:29', '09:31'], 68.5: ['00:53', '11:07'], 48.5: ['04:13', '07:47'], 151.5: ['01:33', '10:27'], 52.5: ['01:15', '10:45'], 6.5: ['04:23', '07:37'], 103.5: ['04:03', '07:57'], 72.5: ['04:35', '07:25'], 54.5: ['02:01', '09:59'], 107.5: ['01:25', '10:35'], 76.5: ['01:57', '10:03'], 132.5: ['02:35', '09:25'], 14.5: ['03:19', '08:41'], 16.5: ['00:03', '11:57'], 167.5: ['00:35', '11:25'], 56.5: ['05:17', '06:43'], 111.5: ['05:07', '06:53'], 80.5: ['03:31', '08:29'], 145.5: ['00:39', '11:21'], 17.5: ['04:25', '07:35'], 175.5: ['01:39', '10:21'], 58.5: ['03:27', '08:33'], 115.5: ['00:21', '11:39'], 84.5: ['03:01', '08:59'], 148.5: ['00:27', '11:33'], 15.5: ['04:19', '07:41'], 18.5: ['03:13', '08:47'], 60.5: ['00:11', '11:49'], 119.5: ['05:49', '06:11'], 88.5: ['02:27', '09:33'], 62.5: ['03:05', '08:55'], 129.5: ['01:29', '10:31'], 123.5: ['00:43', '11:17'], 92.5: ['04:05', '07:55'], 164.5: ['01:41', '10:19'], 20.5: ['05:31', '06:29'], 7.5: ['03:15', '08:45']}
K = [0.0, 5.5, 11.0, 16.5, 22.0, 27.5, 33.0, 38.5, 44.0, 49.5, 55.0, 60.5, 66.0, 71.5, 77.0, 82.5, 88.0, 93.5, 99.0, 104.5, 110.0, 115.5, 121.0, 126.5, 132.0, 137.5, 143.0, 148.5, 154.0, 159.5, 165.0, 170.5, 176.0, 178.5, 173.0, 167.5, 162.0, 156.5, 151.0, 145.5, 140.0, 134.5, 129.0, 123.5, 118.0, 112.5, 107.0, 101.5, 96.0, 90.5, 85.0, 79.5, 74.0, 68.5, 63.0, 57.5, 52.0, 46.5, 41.0, 35.5, 30.0, 24.5, 19.0, 13.5, 8.0, 2.5, 3.0, 8.5, 14.0, 19.5, 25.0, 30.5, 36.0, 41.5, 47.0, 52.5, 58.0, 63.5, 69.0, 74.5, 80.0, 85.5, 91.0, 96.5, 102.0, 107.5, 113.0, 118.5, 124.0, 129.5, 135.0, 140.5, 146.0, 151.5, 157.0, 162.5, 168.0, 173.5, 179.0, 175.5, 170.0, 164.5, 159.0, 153.5, 148.0, 142.5, 137.0, 131.5, 126.0, 120.5, 115.0, 109.5, 104.0, 98.5, 93.0, 87.5, 82.0, 76.5, 71.0, 65.5, 60.0, 54.5, 49.0, 43.5, 38.0, 32.5, 27.0, 21.5, 16.0, 10.5, 5.0, 0.5, 6.0, 11.5, 17.0, 22.5, 28.0, 33.5, 39.0, 44.5, 50.0, 55.5, 61.0, 66.5, 72.0, 77.5, 83.0, 88.5, 94.0, 99.5, 105.0, 110.5, 116.0, 121.5, 127.0, 132.5, 138.0, 143.5, 149.0, 154.5, 160.0, 165.5, 171.0, 176.5, 178.0, 172.5, 167.0, 161.5, 156.0, 150.5, 145.0, 139.5, 134.0, 128.5, 123.0, 117.5, 112.0, 106.5, 101.0, 95.5, 90.0, 84.5, 79.0, 73.5, 68.0, 62.5, 57.0, 51.5, 46.0, 40.5, 35.0, 29.5, 24.0, 18.5, 13.0, 7.5, 2.0, 3.5, 9.0, 14.5, 20.0, 25.5, 31.0, 36.5, 42.0, 47.5, 53.0, 58.5, 64.0, 69.5, 75.0, 80.5, 86.0, 91.5, 97.0, 102.5, 108.0, 113.5, 119.0, 124.5, 130.0, 135.5, 141.0, 146.5, 152.0, 157.5, 163.0, 168.5, 174.0, 179.5, 175.0, 169.5, 164.0, 158.5, 153.0, 147.5, 142.0, 136.5, 131.0, 125.5, 120.0, 114.5, 109.0, 103.5, 98.0, 92.5, 87.0, 81.5, 76.0, 70.5, 65.0, 59.5, 54.0, 48.5, 43.0, 37.5, 32.0, 26.5, 21.0, 15.5, 10.0, 4.5, 1.0, 6.5, 12.0, 17.5, 23.0, 28.5, 34.0, 39.5, 45.0, 50.5, 56.0, 61.5, 67.0, 72.5, 78.0, 83.5, 89.0, 94.5, 100.0, 105.5, 111.0, 116.5, 122.0, 127.5, 133.0, 138.5, 144.0, 149.5, 155.0, 160.5, 166.0, 171.5, 177.0, 177.5, 172.0, 166.5, 161.0, 155.5, 150.0, 144.5, 139.0, 133.5, 128.0, 122.5, 117.0, 111.5, 106.0, 100.5, 95.0, 89.5, 84.0, 78.5, 73.0, 67.5, 62.0, 56.5, 51.0, 45.5, 40.0, 34.5, 29.0, 23.5, 18.0, 12.5, 7.0, 1.5, 4.0, 9.5, 15.0, 20.5, 26.0, 31.5, 37.0, 42.5, 48.0, 53.5, 59.0, 64.5, 70.0, 75.5, 81.0, 86.5, 92.0, 97.5, 103.0, 108.5, 114.0, 119.5, 125.0, 130.5, 136.0, 141.5, 147.0, 152.5, 158.0, 163.5, 169.0, 174.5, 180.0]
T = int(input())
er = 1.0
er = er / 120
while T > 0:
	a = float(input())
	x = float(int(a))
	y = x + 0.5
	z = x + 1.0
	if a in K:
		A = D[a]
		for i in A:
			print(i)
	elif math.fabs(x - a) < er:
		A = D[x]
		for i in A:
			print(i)
	elif math.fabs(y - a) < er:
		A = D[y]
		for i in A:
			print(i)
	elif math.fabs(z - a) < er:
		A = D[z]
		for i in A:
			print(i)
	T = T - 1


from collections import defaultdict
d = defaultdict(lambda : [])
for i in range(12):
	for j in range(60):
		k = abs((i * 60 + j) * 0.5 - j * 6)
		k = min(360 - k, k)
		d[k].append([i, j])
i = 0
t = int(input())
while t > 0:
	f = float(input())
	p = 0.0
	l = f // 0.5
	p = (l - 1) * 0.5
	if abs(f - p) < 1 / 120:
		f = p
	p += 0.5
	if abs(f - p) < 1 / 120:
		f = p
	for i in range(len(d[f])):
		h = str(d[f][i][0])
		m = str(d[f][i][1])
		if len(h) == 1:
			h = '0' + h
		if len(m) == 1:
			m = '0' + m
		print(h + ':' + m)
	t = t - 1