Polycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.

Determine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that period. It is possible that Polycarp begins to sleep in one day, and wakes up in another.


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of alarms.

Each of the next n lines contains a description of one alarm. Each description has a format "hh:mm", where hh is the hour when the alarm rings, and mm is the minute of that hour when the alarm rings. The number of hours is between 0 and 23, and the number of minutes is between 0 and 59. All alarm times are distinct. The order of the alarms is arbitrary.

Each alarm starts ringing in the beginning of the corresponding minute and rings for exactly one minute (i. e. stops ringing in the beginning of the next minute). Polycarp can start sleeping instantly when no alarm is ringing, and he wakes up at the moment when some alarm starts ringing.


-----Output-----

Print a line in format "hh:mm", denoting the maximum time Polycarp can sleep continuously. hh denotes the number of hours, and mm denotes the number of minutes. The number of minutes should be between 0 and 59. Look through examples to understand the format better.


-----Examples-----
Input
1
05:43

Output
23:59

Input
4
22:00
03:21
16:03
09:59

Output
06:37



-----Note-----

In the first example there is only one alarm which rings during one minute of a day, and then rings again on the next day, 23 hours and 59 minutes later. Polycarp can sleep all this time.

Source: codeforces | Difficulty: MEDIUM_HARD


Solutions:
n = int(input())
times = []
for _ in range(n):
	time = str(input())
	times.append((int(time[:2]), int(time[3:])))
times.sort()

def to_minutes(a):
	return 60 * a[0] + a[1]

def to_hours(a):
	return (a // 60, a % 60)

def pad(a):
	return ('0' if a < 10 else '') + str(a)
longest = 0
for i in range(1, n):
	longest = max(longest, to_minutes(times[i]) - to_minutes(times[i - 1]))
longest = max(longest, 60 * 24 + to_minutes(times[0]) - to_minutes(times[n - 1]))
longest -= 1
(hours, minutes) = to_hours(longest)
print(pad(hours), ':', pad(minutes), sep='')


n = int(input())
alarms = []
for i in range(n):
	(h, m) = list(map(int, input().split(':')))
	t = h * 60 + m
	alarms.append(t)
alarms.sort()
alarms.append(alarms[0] + 24 * 60)
mx = -1
for i in range(1, len(alarms)):
	if mx < alarms[i] - alarms[i - 1]:
		mx = alarms[i] - alarms[i - 1]
mx -= 1
print('{:02d}:{:02d}'.format(mx // 60, mx % 60))


n = int(input())
s = ['.'] * n
mx = 0
for i in range(n):
	s[i] = input()
if n == 1:
	print('23:59')
else:
	s = sorted(s)
	for i in range(n):
		i1 = i
		i2 = (i + 1) % n
		col1 = int(s[i1][0:2]) * 60 + int(s[i1][3:5])
		col2 = int(s[i2][0:2]) * 60 + int(s[i2][3:5])
		if col1 > col2:
			if mx < col2 + 60 * 24 - col1 - 1:
				mx = col2 + 60 * 24 - col1 - 1
		elif mx < col2 - col1 - 1:
			mx = col2 - col1 - 1
	print(mx // 60 // 10, mx // 60 % 10, ':', mx % 60 // 10, mx % 60 % 10, sep='')


n = int(input())
p = list()
for i in range(0, n):
	(g, o) = map(int, input().split(':'))
	p.append(g * 60 + o)
p.sort()
answ = 1440 - p[n - 1] + p[0]
for i in range(1, n):
	answ = max(answ, p[i] - p[i - 1])
k = str()
answ = answ - 1
if answ // 60 < 10:
	k = k + '0' + str(answ // 60) + ':'
else:
	k = k + str(answ // 60) + ':'
if answ % 60 < 10:
	k = k + '0' + str(answ % 60)
else:
	k = k + str(answ % 60)
print(k)


n = int(input())
a = []
for i in range(n):
	(m, h) = input().split(':')
	m = int(m)
	h = int(h)
	a.append(m * 60 + h)
a.sort()
ans = 0
for i in range(n):
	ans = max(ans, a[i] - a[i - 1] - 1)
ans = max(ans, 1440 + a[0] - a[-1] - 1)
if n == 1:
	print('23:59')
else:
	hh = ans // 60
	mm = ans % 60
	hh = str(hh)
	mm = str(mm)
	if len(hh) == 1:
		hh = '0' + hh
	if len(mm) == 1:
		mm = '0' + mm
	print(hh + ':' + mm)


from datetime import datetime
from datetime import timedelta
n = int(input())
time = sorted([input() for i in range(n)])
FMT = '%H:%M'
max_time = timedelta.min
for i in range(n - 1):
	t1 = datetime.strptime(time[i], FMT)
	t2 = datetime.strptime(time[i + 1], FMT)
	max_time = max(max_time, t2 - t1 - timedelta(seconds=60))
first = datetime.strptime(time[0], FMT)
last = datetime.strptime(time[n - 1], FMT)
max_time = max(max_time, first - last + timedelta(days=1) - timedelta(seconds=60))
max_time = max_time // timedelta(seconds=60)
print('{:02d}:{:02d}'.format(*divmod(max_time, 60)))


b = int(input())
times = []
line = ''
a = b
while a > 0:
	a -= 1
	curr_time = input().split(':')
	times.append(int(curr_time[0]) * 60 + int(curr_time[1]))
times.sort()
times.append(times[0] + 24 * 60)
max_delta = 0
if times[0] > max_delta:
	max_delta = times[0]
for it in range(1, b + 1):
	if times[it] - times[it - 1] > max_delta:
		max_delta = times[it] - times[it - 1] - 1
if max_delta // 60 < 10:
	first = '0' + str(max_delta // 60)
else:
	first = str(max_delta // 60)
if max_delta - 60 * (max_delta // 60) < 10:
	second = '0' + str(max_delta - 60 * (max_delta // 60))
else:
	second = str(max_delta - 60 * (max_delta // 60))
print(first + ':' + second)


n = int(input())
minutes = []
for i in range(n):
	s = input()
	minutes.append(int(s[:-3]) * 60 + int(s[-2:]))
minutes.sort()
max = 0
for i in range(0, n - 1):
	cur = minutes[i + 1] - minutes[i] - 1
	if cur > max:
		max = cur
cur = 24 * 60 - (minutes[-1] - minutes[0]) - 1
if cur > max:
	max = cur
hours = max // 60
minutes = max - hours * 60
h_str = str(hours)
if len(h_str) < 2:
	h_str = '0' + h_str
m_str = str(minutes)
if len(m_str) < 2:
	m_str = '0' + m_str
print(h_str + ':' + m_str)


n = int(input())
x = []
for i in range(n):
	(a, b) = map(int, input().split(':'))
	x.append(a * 60 + b)
x = sorted(x)
x.append(x[0] + 24 * 60)
m = 0
for i in range(n):
	m = max(m, x[i + 1] - x[i] - 1)
x = str(m // 60)
y = str(m % 60)
if len(x) < 2:
	x = '0' + x
if len(y) < 2:
	y = '0' + y
s = x + ':' + y
print(s)


n = int(input())
a = []
for i in range(n):
	(h, m) = map(int, input().split(':'))
	a += [h * 60 + m]
a.sort()
a += [a[0] + 24 * 60]
ans = -1
for i in range(n):
	ans = max(ans, a[i + 1] - a[i] - 1)
(h, m) = (ans // 60, ans % 60)
if h < 10:
	print(0, end='')
print(h, end=':')
if m < 10:
	print(0, end='')
print(m, end='')


n = int(input())
a = [0] * 1000
for i in range(n):
	s = input()
	t1 = s[0] + s[1]
	t2 = s[3] + s[4]
	a[i] = 60 * int(t1) + int(t2)
for i in range(n):
	for j0 in range(i, n - 1):
		j = n + i - 2 - j0
		if a[j] > a[j + 1]:
			q = a[j + 1]
			a[j + 1] = a[j]
			a[j] = q
a[n] = 24 * 60 + a[0]
mx = a[0]
for i in range(n):
	mx = max(mx, a[i + 1] - a[i] - 1)
q1 = mx // 60
q2 = mx % 60
if q1 == 0:
	s1 = '00'
elif q1 < 10:
	s1 = '0' + str(q1)
else:
	s1 = str(q1)
if q2 == 0:
	s2 = '00'
elif q2 < 10:
	s2 = '0' + str(q2)
else:
	s2 = str(q2)
print(s1 + ':' + s2)


n = int(input())
time = [0 for r in range(2881)]
for i in range(n):
	(h, m) = map(int, input().split(':'))
	time[h * 60 + m] = 1
	time[1440 + h * 60 + m] = 1
ans = 0
cur_ans = 0
for i in range(2881):
	if time[i] != 1:
		cur_ans += 1
		continue
	ans = max(ans, cur_ans)
	cur_ans = 0
h = str(ans // 60)
m = str(ans % 60)
if len(h) == 1:
	h = '0' + h
if len(m) == 1:
	m = '0' + m
print(h + ':' + m)


import datetime
n = int(input())
dts_i = [[int(y) for y in input().split(':')] for x in range(n)]
dts = []
for (h, m) in dts_i:
	dts.append(datetime.datetime(2017, 1, 1, h, m))
for (h, m) in dts_i:
	dts.append(datetime.datetime(2017, 1, 2, h, m))
for (h, m) in dts_i:
	dts.append(datetime.datetime(2017, 1, 3, h, m))
dts = sorted(dts)
pairs = list(zip(dts, dts[1:]))
(lo, hi) = max(pairs, key=lambda xy: xy[1] - xy[0])
delta = hi - lo - datetime.timedelta(minutes=1)
(hours, remainder) = divmod(delta.seconds, 3600)
(minutes, seconds) = divmod(remainder, 60)
print('{0:02d}:{1:02d}'.format(hours, minutes))


n = int(input())
times = [0] * 2880
for _ in range(n):
	(hh, mm) = map(int, input().split(':'))
	t = hh * 60 + mm
	times[t] = 1
	times[t + 1440] = 1
i = 0
res = -1
while i < 1440:
	for j in range(i, i + 1440):
		if times[j] == 1:
			break
	res = max(res, j - i)
	i = j + 1
(hh, mm) = divmod(res, 60)
print('{:02d}:{:02d}'.format(hh, mm))


n = int(input())
t = []
for i in range(n):
	t.append(tuple(map(int, input().split(':'))))
ans = 0
t.sort()
t = t + [(v[0] + 24, v[1]) for v in t]
for i in range(len(t) - 1):
	ans = max(ans, (t[i + 1][0] - t[i][0]) * 60 + (t[i + 1][1] - t[i][1]) - 1)
print('{}:{}'.format(str(ans // 60).rjust(2, '0'), str(ans % 60).rjust(2, '0')))


n = int(input())
day = 24 * 60
v = []
for i in range(n):
	s = input()
	h = int(s[0]) * 10 + int(s[1])
	m = int(s[3]) * 10 + int(s[4])
	tim = h * 60 + m
	v.append(int(tim))
	v.append(int(tim + day))
	v.append(int(tim + day + day))
v.sort()
ans = 0
for i in range(len(v)):
	if i > 0:
		ans = max(ans, v[i] - v[i - 1] - 1)
m = ans % 60
h = ans // 60
print(str(h // 10) + str(h % 10) + ':' + str(m // 10) + str(m % 10))


n = int(input())
z = []
for i in range(n):
	x = input().split(':')
	h = int(x[0])
	m = int(x[1])
	t = 60 * h + m
	z.append(t)
	z.append(t + 24 * 60)
z.sort()
ans = 0
for i in range(0, 2 * n - 1):
	ans = max(ans, z[i + 1] - z[i] - 1)
h = ans // 60
m = ans % 60
print('%02d:%02d' % (h, m))


import sys
n = int(input())
lst = []
p = -1
mx = 0
while n > 0:
	str = input()
	x = 60 * (10 * int(str[0]) + int(str[1])) + 10 * int(str[3]) + int(str[4])
	lst.append(x)
	n -= 1
lst.sort()
for i in lst:
	if p >= 0:
		mx = max(mx, i - p)
	p = i
x = lst[0]
y = lst[-1]
mx = max(mx, x + 1440 - y)
mx -= 1
if mx // 60 < 10:
	print(0, end='')
print(mx // 60, end='')
print(':', end='')
if mx % 60 < 10:
	print(0, end='')
print(mx % 60, end='')


n = int(input())
a = []
for i in range(n):
	(h, m) = map(int, input().split(':'))
	a.append((h + 24) * 60 + m)
	a.append(h * 60 + m)
a.sort()
j = 0
s = 0
ans = 0
for i in range(0, 48 * 60):
	if j < 2 * n and a[j] == i:
		ans = max(ans, s)
		s = 0
		j += 1
		continue
	else:
		s += 1
h = ans // 60
m = ans % 60
hans = ''
mans = ''
if h < 10:
	hans = '0' + str(h)
else:
	hans = str(h)
if m < 10:
	mans = '0' + str(m)
else:
	mans = str(m)
print(hans + ':' + mans)


n = int(input())
a = []
for i in range(n):
	(x, y) = map(int, input().split(':'))
	cur = x * 60 + y
	a.append(cur)
a.sort()
ans = 24 * 60 - a[n - 1] + a[0]
for i in range(n - 1):
	cur_ans = a[i + 1] - a[i]
	ans = max(ans, cur_ans)
ans = ans - 1
x = ans // 60
y = ans % 60
x = str(x)
if len(x) == 1:
	x = '0' + x
y = str(y)
if len(y) == 1:
	y = '0' + y
print('{}:{}'.format(x, y))


n = int(input())
a = []
for i in range(n):
	s = input()
	a.append((int(s[0:2]), int(s[3:5])))
a.sort()
i = 1
res = 0
while i < n:
	res = max(res, a[i][0] * 60 + a[i][1] - (a[i - 1][0] * 60 + a[i - 1][1]) - 1)
	i += 1
res = max(res, (a[0][0] + 24) * 60 + a[0][1] - (a[-1][0] * 60 + a[-1][1]) - 1)
ans = ''
if res // 60 < 10:
	ans += '0'
ans += str(res // 60)
ans += ':'
if res % 60 < 10:
	ans += '0'
ans += str(res % 60)
print(ans)


n = int(input())
a = []
for _ in range(n):
	s = list(map(int, input().split(':')))
	a.append(s[0] * 60 + s[1])
if n == 1:
	print('23:59')
else:
	b = []
	for i in a:
		b.append(24 * 60 + i)
	a = a + b
	a.sort()
	mx = 0
	for i in range(1, len(a)):
		mx = max(mx, a[i] - a[i - 1])
	mx -= 1
	s = ''
	h = str(mx // 60)
	if len(h) == 1:
		h = '0' + h
	m = str(mx % 60)
	if len(m) == 1:
		m = '0' + m
	s = h + ':' + m
	print(s)


import sys
n = int(input())
if n == 1:
	print('23:59')
	sys.exit()
a = []
for i in range(n):
	(k, b) = map(int, input().split(':'))
	a += [k * 60 + b]
a = sorted(a)
mn = 0
for i in range(1, n):
	mn = max(mn, a[i] - a[i - 1])
mn = max(mn, 24 * 60 - a[n - 1] + a[0])
mn -= 1
s = ''
if mn // 60 < 10:
	s += '0'
s += str(mn // 60)
s += ':'
if mn % 60 < 10:
	s += '0'
s += str(mn % 60)
print(s)


def formatted_number(number):
	if number < 10:
		return '0' + str(number)
	return str(number)

def print_max_duration(time):
	hh = time // 60
	mm = time - hh * 60
	print(formatted_number(hh) + ':' + formatted_number(mm))

def parse_minutes(time):
	hh = int(time[0:2])
	mm = int(time[3:])
	return hh * 60 + mm

def main():
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(parse_minutes(input()))
	arr = sorted(arr)
	max_duration = 0
	for i in range(n - 1):
		max_duration = max(max_duration, arr[i + 1] - arr[i] - 1)
	max_duration = max(max_duration, 24 * 60 - arr[n - 1] - 1 + arr[0])
	print_max_duration(max_duration)
main()


n = int(input())
time = [None] * n
for i in range(n):
	t = input()
	(h, m) = t.split(':')
	(h, m) = (int(h), int(m))
	num = h * 60 + m
	time[i] = num
time.sort()
time.append(time[0] + 1440)
ans = time[1] - time[0] - 1
for i in range(i + 1):
	ans = max(ans, time[i + 1] - time[i] - 1)
print('{:02d}:{:02d}'.format(*divmod(ans, 60)))


n = int(input())
h = [0] * n
m = [0] * n
for i in range(0, n):
	(h[i], m[i]) = map(int, input().split(':'))
for i in range(0, n):
	for j in range(i, n):
		if h[j] < h[i] or (h[j] == h[i] and m[j] < m[i]):
			t = h[j]
			h[j] = h[i]
			h[i] = t
			t = m[j]
			m[j] = m[i]
			m[i] = t
mxh = 0
mxm = 0
for i in range(0, n):
	if i == n - 1:
		nowh = h[0] + 24 - h[i]
		nowm = m[0] - m[i] - 1
		if nowm < 0:
			nowh = nowh - 1
			nowm = nowm + 60
		if mxh < nowh or (mxh == nowh and mxm < nowm):
			mxh = nowh
			mxm = nowm
	else:
		nowh = h[i + 1] - h[i]
		nowm = m[i + 1] - m[i] - 1
		if nowm < 0:
			nowh = nowh - 1
			nowm = nowm + 60
		if mxh < nowh or (mxh == nowh and mxm < nowm):
			mxh = nowh
			mxm = nowm
print('%02d:%02d' % (mxh, mxm))


n = int(input())
a = []
for i in range(n):
	str = input()
	h = int(str[0:2]) * 60
	m = int(str[3:5])
	a.append(h + m)
a.sort()
mx = 0
for i in range(n - 1):
	if mx < -a[i] + a[i + 1] - 1:
		mx = -a[i] + a[i + 1] - 1
if mx < 1440 + a[0] - a[n - 1] - 1:
	mx = 1440 + a[0] - a[n - 1] - 1
if mx // 60 < 10:
	print('0', end='')
print(mx // 60, end='')
print(':', end='')
if mx % 60 < 10:
	print('0', end='')
print(mx % 60)


def val(c):
	return ord(c) - ord('0')

def minutes(t):
	res = val(t[0]) * 10 * 60 + val(t[1]) * 60 + val(t[3]) * 10 + val(t[4])
	return res

def time_format(mx):
	h = mx // 60
	m = mx % 60
	h = str(h)
	m = str(m)
	if len(h) == 1:
		h = '0' + h
	if len(m) == 1:
		m = '0' + m
	return h + ':' + m
n = int(input())
t = []
s = ''
for _ in range(n):
	s = input()
	t.append(minutes(s))
t.sort()
mx = 0
for i in range(len(t) - 1):
	mx = max(mx, t[i + 1] - t[i])
mx = max(mx, 24 * 60 - t[-1] + t[0])
mx -= 1
print(time_format(mx))


n = int(input())
a = []

def mem(kek):
	return (int(kek[0]) * 10 + int(kek[1])) * 60 + int(kek[3]) * 10 + int(kek[4])

def lol(kek):
	h = str(kek // 60)
	m = str(kek % 60)
	ans = ''
	if len(h) < 2:
		ans += '0'
	ans += h
	ans += ':'
	if len(m) < 2:
		ans += '0'
	ans += m
	return ans
delt = 60 * 24
for i in range(n):
	st = input()
	a.append(mem(st))
	a.append(mem(st) + delt)
	a.append(mem(st) + 2 * delt)
a = sorted(a)
ans = 0
for i in range(1, len(a)):
	ans = max(ans, a[i] - a[i - 1] - 1)
print(lol(ans))


n = int(input())
alarms = []
for i in range(n):
	line = [int(x) for x in input().strip().split(':')]
	alarms.append(line[0] * 60 + line[1])
alarms = sorted(alarms)
tmp = [1440 + x for x in alarms]
alarms += tmp
ans = 0
for i in range(1, len(alarms)):
	if i > 0:
		ans = max(ans, alarms[i] - alarms[i - 1] - 1)
print('%02d:%02d' % (ans // 60, ans % 60))


def f(x):
	if x < 10:
		return '0' + str(x)
	return str(x)
n = int(input())
times = []
for i in range(0, n):
	s = input()
	times.append(60 * int(s[0:2]) + int(s[3:5]))
	times.append(60 * 24 + 60 * int(s[0:2]) + int(s[3:5]))
times.sort()
ans = times[1] - times[0] - 1
for i in range(1, len(times)):
	ans = max(ans, times[i] - times[i - 1] - 1)
print('{}:{}'.format(f(ans // 60), f(ans % 60)))


def toInt(s):
	return (int(s[0]) * 10 + int(s[1])) * 60 + int(s[3]) * 10 + int(s[4])

def mx(a, b):
	if a > b:
		return a
	return b

def convert(val):
	return '%d%d:%d%d' % (val // 60 % 24 // 10, val // 60 % 24 % 10, val % 60 // 10, val % 60 % 10)
n = int(input())
arr = []
for i in range(n):
	arr.append(input())
arr.sort()
ans = 0
for i in range(n - 1):
	ans = mx(ans, (toInt(arr[i + 1]) - toInt(arr[i]) - 1 + 1440) % 1440)
ans = mx(ans, (1440 - toInt(arr[n - 1]) + toInt(arr[0]) - 1 + 1440) % 1440)
print(convert(ans))


n = int(input())
arr = []
for i in range(n):
	(h, m) = map(int, input().split(':'))
	cur = h * 60 + m
	arr.append(cur)
arr.sort()
arr.append(24 * 60 + arr[0])
maxx = 0
for i in range(1, len(arr)):
	maxx = max(maxx, arr[i] - arr[i - 1] - 1)
m = maxx % 60
h = maxx // 60
if h < 10:
	print(0, end='')
print(h, ':', sep='', end='')
if m < 10:
	print(0, end='')
print(m)


our = []
for i in range(int(input())):
	s = input()
	our.append(int(s[0:2]) * 60 + int(s[3:]))
our.sort()
our.append(our[0] + 24 * 60)
res = 0
for i in range(len(our) - 1):
	res = max(res, our[i + 1] - our[i])
res -= 1
hour = str(res // 60)
minute = str(res % 60)
if len(hour) < 2:
	hour = '0' + hour
if len(minute) < 2:
	minute = '0' + minute
print(hour + ':' + minute)


def dist(a, b):
	minsa = int(a.split(':')[0]) * 60 + int(a.split(':')[1])
	minsb = int(b.split(':')[0]) * 60 + int(b.split(':')[1])
	return minsb - minsa - 1

def ldist(a, b):
	minsa = (int(a.split(':')[0]) + 24) * 60 + int(a.split(':')[1])
	minsb = int(b.split(':')[0]) * 60 + int(b.split(':')[1])
	return minsa - minsb - 1
a = int(input())
x = []
for i in range(a):
	t = input()
	x.append(t)
x = sorted(x)
ans = 0
for i in range(0, len(x) - 1):
	r = dist(x[i], x[i + 1])
	ans = max(r, ans)
ans = max(ans, ldist(x[0], x[len(x) - 1]))
h = ans // 60
m = ans - h * 60
if h < 10:
	if m < 10:
		print('0' + str(h) + ':0' + str(m))
	else:
		print('0' + str(h) + ':' + str(m))
elif m < 10:
	print(str(h) + ':0' + str(m))
else:
	print(str(h) + ':' + str(m))


n = int(input())
a = []
for i in range(n):
	b = input().split(':')
	a.append(int(b[0]) * 60 + int(b[1]))
a.sort()
t = a[0]
for i in range(n):
	a[i] -= t
a.append(1440)
u = -1
for i in range(n):
	u = max(u, a[i + 1] - a[i] - 1)
h = u // 60
m = u - h * 60
if h < 10:
	print('0', end='')
print(h, end=':')
if m < 10:
	print('0', end='')
print(m, end='')


import math
for tes in range(1):
	n = int(input())
	L = [0]
	for i in range(n):
		s = str(input())
		s = s.split(':')
		L.append(int(s[0]) * 60 + int(s[1]))
	L.sort()
	L.append(24 * 60 + L[1])
	ans = 0
	for i in range(1, len(L)):
		ans = max(ans, L[i] - L[i - 1])
	ans -= 1
	h = ans // 60
	sec = ans % 60
	if h < 10:
		h = '0' + str(h)
	else:
		h = str(h)
	if sec < 10:
		sec = '0' + str(sec)
	else:
		sec = str(sec)
	print(h + ':' + sec)


n = int(input())
A = []
for i in range(n):
	s = input()
	h = s[:2]
	m = s[3:]
	A.append((int(h), int(m)))
md = -12341234
A = sorted(A)
for i in range(n - 1):
	(a, b) = A[i]
	(c, d) = A[i + 1]
	g = (c - a) * 60
	if b > d:
		g += 60 - b + d
		g -= 60
	else:
		g += d - b
	if g > md:
		md = g
(a, b) = A[0]
(c, d) = A[n - 1]
g = (24 - c + a) * 60
g += 60 - d + b
g -= 60
if g > md:
	md = g
md -= 1
if md // 60 < 10:
	print('0', sep='', end='')
print(md // 60, ':', sep='', end='')
if md % 60 < 10:
	print('0', sep='', end='')
print(md % 60)