Read problems statements in Mandarin Chinese here 
Read problems statements in Russian here 

------ Problem Statement ------ 

One day Chef is waiting his girlfriend on the bus station. The girlfriend said that she will be at time_{1}. Chef went to the bus station at time_{2}. When Chef has reached the bus station he realized that he forgot a gift for his better half in his home.

Chef knows that someone can reach his home in dist minutes (his girlfriend also needs dist minutes to get Chef's home after she arrived at the bus station). So, Chef came up with two plans for present the gift:
i. The first one is to wait for his girlfriend at the bus station. And then go to the home together with her. When Chef and his girlfriend will reach the home he will present his gift. 
ii. The second one is to call the girlfriend and ask her to go to his home when she will reach the bus station. And after calling he will go to the home, take the gift, and go towards the girlfriend. When they meet each other he will present his gift (they can meet at any position of the road or at the bus station). It's known that girlfriend and Chef uses the same road between bus station and Chef's home.
Please, help Chef to estimate the time in minutes for each of his plans. 

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

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. 
Each test case contains of three lines. The first line contains time_{1}, the second line contains time_{2}, and the third line contains dist. 

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

For each test case output a single line containing two real numbers - the time for the first plan and the time for the second one. Print real numbers with exactly one decimal digit after the dot.

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

$1 ≤ T ≤ 10000;$
$1 ≤ dist ≤ 180.$
$Two times are given in form HH:MM (usual time from 00:00 to 23:59), and these two times are from the same day. It's guaranteed that Chef will be at bus station strictly earlier that his girlfriend.$

----- Sample Input 1 ------ 
3
10:00
09:00
10
10:00
09:00
30
10:00
09:00
60
----- Sample Output 1 ------ 
70.0 60.0
90.0 60.0
120.0 90.0

Difficulty: MEDIUM
Tags: Constructive algorithms

Ad-hoc

Starter code:

Solutions:
for _ in range(int(input())):
	t1 = input()
	t2 = input()
	x = int(input())
	a = int(t1[0:2])
	b = int(t1[3:5])
	m = a * 60 + b
	a = int(t2[0:2])
	b = int(t2[3:5])
	n = a * 60 + b
	print(float(m - n + x), end=' ')
	if 2 * x <= m - n:
		print(float(m - n))
	else:
		y = 2 * x - (m - n)
		print(float(m - n + y / 2))


for _ in range(int(input())):
	(x, y) = map(int, input().split(':'))
	(m, n) = map(int, input().split(':'))
	dist = int(input())
	x = x * 60 + y
	m = m * 60 + n
	print((x - m + dist) / 1.0, end=' ')
	if x - m >= 2 * dist:
		print((x - m) / 1.0)
	else:
		print(((x - m) / 2 + dist) / 1.0)


t = int(input())
for c in range(t):
	(h1, m1) = list(map(int, input().split(':')))
	(h2, m2) = list(map(int, input().split(':')))
	dist = int(input())
	t1 = h1 * 60 + m1
	t2 = h2 * 60 + m2
	p1 = t1 - t2 + dist
	p2 = t1 - t2
	if dist * 2 > t1 - t2:
		if t1 == t2 + dist:
			p2 += dist / 2
		else:
			p2 = dist + (t1 - t2) / 2
	print(float(p1), float(p2))


t = int(input())
while t:
	s1 = input()
	s2 = input()
	n = int(input())
	a = int(s1[0] + s1[1])
	b = int(s1[3] + s1[4])
	c = int(s2[0] + s2[1])
	d = int(s2[3] + s2[4])
	x = a * 60 + b
	y = c * 60 + d
	r = float('%.1f' % (x - y + n))
	print(r, end=' ')
	print(float('%.1f' % (x - y))) if 2 * n < x - y else print((2 * n + (x - y)) / 2)
	t -= 1


t = int(input(''))
for _ in range(t):
	t1 = input().split(':')
	t2 = input().split(':')
	t12 = (int(t1[0]) - int(t2[0])) * 60 + (int(t1[1]) - int(t2[1]))
	d = int(input(''))
	if t12 == 0:
		print('0.0 0.0')
	x1 = t12 + d
	if t12 < 2 * d:
		x2 = d + t12 / 2
	else:
		x2 = t12
	print('{:.1f} {:.1f}'.format(x1, x2))


for _ in range(int(input())):
	time1 = input()
	time2 = input()
	dist = int(input())
	time1_h = int(time1[:2])
	time1_m = int(time1[3:])
	time2_h = int(time2[:2])
	time2_m = int(time2[3:])
	t1 = time1_h * 60 + time1_m
	t2 = time2_h * 60 + time2_m
	if 2 * dist < t1 - t2:
		print((t1 - t2 + dist) / 1, (t1 - t2) / 1)
	else:
		print((t1 - t2 + dist) / 1, (2 * dist + (t1 - t2)) / 2)


class Time:

	def __init__(self, hh, mm):
		self.hh = int(hh)
		self.mm = int(mm)

	@staticmethod
	def minDiff(time1, time2):
		mins1 = time1.hh * 60 + time1.mm
		mins2 = time2.hh * 60 + time2.mm
		return abs(mins1 - mins2)

	@staticmethod
	def addMins(time1, mins):
		mins1 = time1.hh * 60 + time1.mm
		mins += mins1
		t = Time('00', '00')
		t.hh = mins // 60
		t.mm = mins % 60
		return t
tc = int(input())
for _ in range(1, 1 + tc):
	timeStr = input()
	time1 = Time(timeStr.split(':')[0], timeStr.split(':')[1])
	timeStr = input()
	time2 = Time(timeStr.split(':')[0], timeStr.split(':')[1])
	dist = float(input())
	tdiff = Time.minDiff(time1, time2)
	case1 = float(tdiff + dist)
	if tdiff >= 2 * dist:
		case2 = tdiff
	else:
		chefAtHouse = Time.addMins(time2, dist)
		atHouse_atStation = Time.minDiff(time1, chefAtHouse)
		case2 = max(tdiff, dist) + abs(dist - atHouse_atStation) / 2
	case2 = float(case2)
	print(case1, case2)


t = int(input())
for i in range(t):
	t1 = input()
	t2 = input()
	dist = int(input())
	t1_h = int(t1[:2])
	t1_m = int(t1[3:])
	t2_h = int(t2[:2])
	t2_m = int(t2[3:])
	a = t1_h * 60 + t1_m
	b = t2_h * 60 + t2_m
	if 2 * dist < a - b:
		print((a - b + dist) / 1, (a - b) / 1)
	else:
		print((a - b + dist) / 1, (2 * dist + (a - b)) / 2)


for _ in range(int(input())):
	t1 = input()
	t2 = input()
	dist = int(input())
	(h1, m1) = map(int, t1.split(':'))
	(h2, m2) = map(int, t2.split(':'))
	t1 = h1 * 60 + m1
	t2 = h2 * 60 + m2
	dif = t1 - t2
	a1 = dif + dist
	if dist * 2 < dif:
		a2 = dif
	else:
		a2 = dif + (2 * dist - dif) / 2
	a1 = a1 * 10 / 10
	a2 = a2 * 10 / 10
	print(a1, a2)


get_int = lambda : int(input())
get_mint = lambda : list(map(int, input().split()))
t = input()
for c in range(0, int(t)):
	(h1, m1) = list(map(int, input().split(':')))
	(h2, m2) = list(map(int, input().split(':')))
	dist = get_int()
	(time1, time2) = (h1 * 60 + m1, h2 * 60 + m2)
	base = time1 - time2
	plan1 = base + dist
	plan2 = base
	if dist * 2 > base:
		if time1 == time2 + dist:
			plan2 += dist / 2
		else:
			plan2 = dist + base / 2
	print('%.1f ' % plan1, '%.1f' % plan2)


t = int(input())
while t > 0:
	t1 = input()
	t2 = input()
	dist = int(input())
	t1_h = int(t1[0:2])
	t1_m = int(t1[3:])
	t2_h = int(t2[0:2])
	t2_m = int(t2[3:])
	t1 = t1_h * 60 + t1_m
	t2 = t2_h * 60 + t2_m
	if 2 * dist < t1 - t2:
		print((t1 - t2 + dist) / 1, (t1 - t2) / 1)
	else:
		print((t1 - t2 + dist) / 1, (2 * dist + (t1 - t2)) / 2)
	t -= 1


for t in range(int(input())):
	t1 = list(map(int, input().split(':')))
	t2 = list(map(int, input().split(':')))
	d = float(input())
	a = float(t1[0] * 60 + t1[1] - t2[0] * 60 - t2[1])
	p1 = a + d
	if 2 * d <= a:
		p2 = a
	else:
		p2 = a / 2 + d
	print(p1, p2)


for _ in range(int(input())):
	a = input()
	b = input()
	d = int(input())
	ans1 = float((int(a[:2]) - int(b[:2])) * 60 + (int(a[3:]) - int(b[3:])) + d)
	k = ans1 - d
	ans2 = k if 2 * d <= k else d + k / 2 if d <= k else d + k / 2
	print(ans1, ans2)


def solve(hrs, mina):
	mina = hrs * 60 + mina
	return mina
for _ in range(int(input())):
	time1 = input()
	time2 = input()
	time1h = time1[:2]
	time1m = time1[3:]
	time2h = time2[:2]
	time2m = time2[3:]
	if time1h[0] == '0':
		time1h = time1h[1]
	if time1m[0] == '0':
		time1m = time1m[1]
	if time2h[0] == '0':
		time2h = time2h[1]
	if time2m[0] == '0':
		time2m = time2m[1]
	time1 = solve(int(time1h), int(time1m))
	time2 = solve(int(time2h), int(time2m))
	dist = int(input())
	case1 = time1 - time2 + dist
	case2 = time1 - time2
	if 2 * dist > case2:
		case2 = (case2 + 2 * dist) / 2
	print(format(case1, '.1f'), format(case2, '.1f'))


for _ in range(int(input())):
	time1 = list(map(int, input().split(':')))
	time2 = list(map(int, input().split(':')))
	dist = float(input())
	a = float(time1[0] * 60 + time1[1] - time2[0] * 60 - time2[1])
	x = dist + a
	if 2 * dist <= a:
		y = a
	else:
		y = a / 2 + dist
	print(x, y)


for _ in range(int(input())):
	(t1, t2) = (input(), input())
	dist = int(input())
	(h1, mi1) = (int(t1[0] + t1[1]), int(t1[3] + t1[4]))
	(h2, mi2) = (int(t2[0] + t2[1]), int(t2[3] + t2[4]))
	mdiff = mi1 - mi2
	hdiff = h1 - h2
	total_A = hdiff * 60 + mdiff + dist
	if 2 * dist <= hdiff * 60 + mdiff:
		total_B = hdiff * 60 + mdiff
	else:
		total_B = hdiff * 60 + mdiff + (2 * dist - (hdiff * 60 + mdiff)) / 2
	print('%.1f %.1f' % (total_A, total_B))


def gf(a, b, c, d, dist):
	a1 = 60 * a + b
	a2 = 60 * c + d
	print((a1 - a2 + dist) / 1.0, end=' ')
	if a1 - a2 >= 2 * dist:
		print((a1 - a2) / 1.0)
	else:
		print(((a1 - a2) / 2 + dist) / 1.0)
t = int(input())
for i in range(t):
	s1 = input()
	a = int(s1[:2])
	b = int(s1[3:])
	s2 = input()
	c = int(s2[:2])
	d = int(s2[3:])
	dist = int(input())
	gf(a, b, c, d, dist)


t = int(input())
for i in range(t):
	t1 = str(input())
	t2 = str(input())
	dis = int(input())
	tl = (int(t1[0] + t1[1]) - int(t2[0] + t2[1])) * 60 + (int(t1[3] + t1[4]) - int(t2[3] + t2[4]))
	p1 = tl + dis
	if 2 * dis <= tl:
		p2 = tl
	elif dis <= tl:
		p2 = float(dis + (tl - dis)) + (dis - (tl - dis)) / 2
	elif dis > tl:
		p2 = float(dis) + tl / 2
	print(float(p1), float(p2))


from time import *
for _ in range(int(input())):
	t1 = list(map(int, input().split(':')))
	t1 = t1[0] * 60 + t1[1]
	t2 = list(map(int, input().split(':')))
	t2 = t2[0] * 60 + t2[1]
	d = float(input())
	x = float(t1 - t2)
	if 2 * d < x:
		print(round(d + x, 1), round(x, 1))
	else:
		print(round(d + x, 1), round(d + x / 2, 1))


T = int(input())

def timediff(t1, t2):
	hour1 = int(t1[0:2])
	minute1 = int(t1[3:5])
	hour2 = int(t2[0:2])
	minute2 = int(t2[3:5])
	time1 = hour1 * 60 + minute1
	time2 = hour2 * 60 + minute2
	difference = time1 - time2
	return difference

def plana(diff, dist):
	result = diff + dist
	return result

def planb(diff, dist):
	if diff > 2 * dist:
		result = diff
	else:
		result = 0.5 * diff + dist
	return result

def process():
	t1 = input()
	t2 = input()
	dist = int(input())
	diff = timediff(t1, t2)
	a = plana(diff, dist)
	b = planb(diff, dist)
	print('%.1f' % a, end=' ')
	print('%.1f' % b)
for index in range(0, T):
	process()


reply = []
for _ in range(int(input())):
	girl = []
	for i in input().split(':'):
		girl.append(int(i))
	chef = []
	for i in input().split(':'):
		chef.append(int(i))
	home = int(input())
	a = 60 * girl[0] + girl[1] - (60 * chef[0] + chef[1]) + home
	if 2 * home >= a - home:
		b = (60 * girl[0] + girl[1] - (60 * chef[0] + chef[1])) / 2 + home
	else:
		b = a - home
	reply.append((a, b))
for i in reply:
	print('{0:.1f}'.format(i[0]), '{0:.1f}'.format(i[1]))


T = int(input())

def time(t1, t2):
	t3 = [0, 0]
	t3[0] = t1[0] - t2[0]
	t3[1] = t1[1] - t2[1]
	if t3[1] < 0:
		t3[1] = 60 + t3[1]
		t3[0] -= 1
	return t3

def minu(t):
	return t[0] * 60 + t[1]
for x in range(T):
	t1 = list(map(int, input().split(':')))
	t2 = list(map(int, input().split(':')))
	t1 = t1[0] * 60 + t1[1]
	t2 = t2[0] * 60 + t2[1]
	dist = int(input())
	t1 -= t2
	t2 = 0
	ans1 = t1 + dist
	if 2 * dist <= t1:
		ans2 = t1
	elif dist > t1:
		ans2 = dist + t1 / 2
	else:
		h = t1 - dist
		ans2 = dist + h + (dist - h) / 2
	print(float(ans1), float(ans2))


def difftime(t1, t2):
	t3 = [0, 0]
	t3[0] = t1[0] - t2[0]
	t3[1] = t1[1] - t2[1]
	if t3[1] < 0:
		t3[1] = 60 + t3[1]
		t3[0] -= 1
	return t3

def tomin(t):
	return t[0] * 60 + t[1]
for x in range(int(input())):
	t1 = list(map(int, input().split(':')))
	t2 = list(map(int, input().split(':')))
	dist = int(input())
	r = tomin(difftime(t1, t2))
	a = str(r + float(dist)) + ' '
	if 2 * dist <= r:
		a += str(float(r))
	else:
		a += str(float(r + (2 * dist - r) / 2))
	print(a)


t = int(input())
for i in range(t):
	t1 = input()
	t2 = input()
	t3 = int(input())
	l1 = t1.split(':')
	l2 = t2.split(':')
	t1 = float(l1[0]) * 60.0 + float(l1[1])
	t2 = float(l2[0]) * 60.0 + float(l2[1])
	h1 = abs(t1 - t2) + float(t3)
	print(round(h1, 1), end=' ')
	h2 = abs(t1 - t2)
	if 2 * t3 > h2:
		print(round(t3 + h2 / 2, 1))
	else:
		print(round(h2, 1))


t = int(input())
for _ in range(t):
	time1 = input()
	time2 = input()
	dist = int(input())
	time1_h = int(time1[0:2])
	time1_m = int(time1[3:])
	time2_h = int(time2[0:2])
	time2_m = int(time2[3:])
	time1 = time1_h * 60 + time1_m
	time2 = time2_h * 60 + time2_m
	if 2 * dist < time1 - time2:
		print((time1 - time2 + dist) / 1, (time1 - time2) / 1)
	else:
		print((time1 - time2 + dist) / 1, (2 * dist + (time1 - time2)) / 2)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split(':'))
	(m, n) = map(int, input().split(':'))
	x = x * 60 + y
	m = m * 60 + n
	d = x - m
	dist = int(input())
	T1 = (dist + d) / 1.0
	if d >= dist * 2:
		T2 = d / 1.0
	else:
		T2 = (dist + d / 2) / 1.0
	print(T1, T2)


for k in range(int(input())):
	(t1, h1) = map(int, input().split(':'))
	(t2, h2) = map(int, input().split(':'))
	dist = int(input())
	time_interval = (t1 - t2) * 60.0 + h1 - h2
	print(time_interval + dist, end=' ')
	if time_interval >= 2 * dist:
		print(time_interval)
	else:
		result = (2 - time_interval / dist) * (dist / 2) + time_interval
		print(round(result, 1))


t = int(input())
while t > 0:
	t -= 1
	time1 = input()
	time2 = input()
	t1 = int(time1[:2]) * 60 + int(time1[3:])
	t2 = int(time2[:2]) * 60 + int(time2[3:])
	dist = int(input())
	c1 = dist + t1 - t2
	c2 = t1 - t2 if dist * 2 <= t1 - t2 else (t1 - t2) / 2 + dist
	print('{:.1f}'.format(c1), end=' ')
	print('{:.1f}'.format(c2))


t = int(input())
for _ in range(t):
	time1 = input().split(':')
	time2 = input().split(':')
	dist = int(input())
	diff = (int(time1[0]) - int(time2[0])) * 60 + (int(time1[1]) - int(time2[1]))
	time_for_fst_plan = diff + dist
	print(time_for_fst_plan / 1, end=' ')
	if dist <= diff // 2:
		time_for_scnd_plan = diff
		print(time_for_scnd_plan / 1)
	else:
		time_for_scnd_plan = dist + (diff - dist) + (2 * dist - diff) / 2
		print(time_for_scnd_plan)


t = int(input())
for i in range(t):
	t1 = input()
	t2 = input()
	dist = int(input())
	s1 = int(t1[0]) * 10 + int(t1[1])
	m1 = int(t1[3]) * 10 + int(t1[4])
	s2 = int(t2[0]) * 10 + int(t2[1])
	m2 = int(t2[3]) * 10 + int(t2[4])
	diff = s1 * 60 + m1 - (s2 * 60 + m2)
	if diff >= 2 * dist:
		k = diff
	else:
		k = (2 * dist + diff) / 2
	print('%.1f' % (diff + dist), '%.1f' % k)


tests = int(input())
for i in range(tests):
	time1 = list(map(int, input().split(':')))
	time2 = list(map(int, input().split(':')))
	dist = int(input())
	time_gap = (time1[0] - time2[0]) * 60
	min_gap = abs(time1[1] - time2[1])
	if time2[1] > time1[1]:
		time_gap -= min_gap
	else:
		time_gap += min_gap
	case1_time = float(time_gap + dist)
	if dist * 2 <= time_gap:
		case2_time = time_gap
	else:
		remaining = (dist * 2 - time_gap) / 2
		case2_time = time_gap + remaining
	print(case1_time, float(case2_time))


import math
T = int(input())
for i in range(T):
	(h1, m1) = [int(i) for i in input().split(':')]
	(h2, m2) = [int(j) for j in input().split(':')]
	dist = int(input())
	p1 = (h1 - h2) * 60 + (m1 - m2) + dist
	p1 = '{0:.1f}'.format(p1)
	home = dist
	gap = (h1 - h2) * 60 + (m1 - m2)
	p2 = 0.0
	if gap >= 2 * dist:
		p2 += gap
	else:
		p2 += dist
		temp1 = h2 * 60 + m2
		temp2 = h1 * 60 + m1
		p2 += (temp2 - temp1) / 2
		p2 = '{0:.1f}'.format(p2)
	print(p1, p2)


for _ in range(int(input())):
	s1 = input()
	s2 = input()
	n = int(input())
	a = int(s1[0] + s1[1])
	b = int(s1[3] + s1[4])
	c = int(s2[0] + s2[1])
	d = int(s2[3] + s2[4])
	x = a * 60 + b
	y = c * 60 + d
	r = float('%.1f' % (x - y + n))
	print(r, end=' ')
	print(float('%.1f' % (x - y))) if 2 * n < x - y else print((2 * n + (x - y)) / 2)


for _ in range(int(input())):
	time1 = input()
	time2 = input()
	dist = int(input())
	h1 = int(time1[0]) * 10 + int(time1[1])
	m1 = int(time1[3]) * 10 + int(time1[4])
	h2 = int(time2[0]) * 10 + int(time2[1])
	m2 = int(time2[3]) * 10 + int(time2[4])
	h = h1 - h2
	if m1 < m2:
		m = m1 + 60 - m2
		h -= 1
	else:
		m = m1 - m2
	t = h * 60 + m
	t1 = t + dist / 1
	if 2 * dist <= t:
		t2 = t / 1
	else:
		t2 = dist + t / 2
	print(str(t1) + ' ' + str(t2))


from sys import stdin, stdout
stdint = lambda : int(stdin.readline())
stdstr = lambda : stdin.readline().strip()

def getMins(s):
	(h, m) = map(int, s.split(':'))
	return h * 60 + m
for _ in range(stdint()):
	gf = stdstr()
	chef = stdstr()
	d = stdint()
	minsGf = getMins(gf)
	minsChef = getMins(chef)
	if 2 * d <= minsGf - minsChef:
		ans = minsGf - minsChef
	else:
		ans = (minsGf - minsChef) / 2 + d
	print(float(minsGf - minsChef + d), float(ans))


for _ in range(int(input())):
	t1 = input()
	t2 = input()
	dist = int(input())
	t12 = t1.split(':')
	t22 = t2.split(':')
	t1f = int(t12[0]) * 60 + int(t12[1])
	t2f = int(t22[0]) * 60 + int(t22[1])
	tdif = t1f - t2f
	ta = tdif + dist
	if tdif > 2 * dist:
		print(ta / 1, tdif / 1)
	else:
		tf = dist - tdif
		tx = (dist - tf) / 2
		tff = tf + tx + tdif
		print(ta / 1, tff)


for _ in range(int(input())):
	(t1h, t1m) = map(int, input().split(':'))
	(t2h, t2m) = map(int, input().split(':'))
	distt = int(input())
	t1 = t1h * 60 + t1m
	t2 = t2h * 60 + t2m
	o1 = t1
	o2 = t2
	ans1 = t1 - t2 + distt
	ans2 = 0
	if t2 + distt + distt <= t1:
		ans2 = t1 - t2
	else:
		t2 = t2 + distt
		girlmove = t2 - t1
		ans2 = o1 - o2 + girlmove + (distt - girlmove) / 2
	ans1 = '{:.1f}'.format(round(ans1, 1))
	ans2 = '{:.1f}'.format(round(ans2, 1))
	print(str(ans1) + ' ' + str(ans2))


for _ in range(int(input())):
	time_gf = input()
	time_chef = input()
	dist = int(input())
	time_gf = int(time_gf[:2]) * 60 + int(time_gf[3:])
	time_chef = int(time_chef[:2]) * 60 + int(time_chef[3:])
	plan1 = float(time_gf - time_chef + dist)
	if time_gf >= time_chef + dist + dist:
		print(plan1, float(time_gf - time_chef))
	elif time_gf <= time_chef + dist:
		time_apart = time_gf - time_chef
		print(plan1, float(dist + time_apart / 2))
	else:
		z = time_gf - time_chef
		s = z - dist
		f = dist - s
		print(plan1, z + f / 2)


for _ in range(int(input())):
	t1 = input()
	t2 = input()
	dist = int(input())
	(hours1, minutes1) = map(int, t1.split(':'))
	(hours2, minutes2) = map(int, t2.split(':'))
	girlfriend_arrival_station = 60 - minutes2 + minutes1 + (hours1 - hours2 - 1) * 60
	if 2 * dist < girlfriend_arrival_station:
		second = float(girlfriend_arrival_station)
	else:
		second = float(girlfriend_arrival_station + (2 * dist - girlfriend_arrival_station) / 2)
	first = float(girlfriend_arrival_station + dist)
	print(first, second)


for _ in range(int(input())):
	(h1, m1) = map(int, input().split(':'))
	m1 += 60 * h1
	(h2, m2) = map(int, input().split(':'))
	m2 += 60 * h2
	d = int(input())
	m = m1 - m2
	print(float(m + d), end=' ')
	if m >= 2 * d:
		print(float(m))
	else:
		print(float(d + m / 2))


for t in range(int(input())):
	t1 = input()
	t2 = input()
	d = int(input())
	a = int(t1[:2]) * 60 + int(t1[3:]) - int(t2[:2]) * 60 - int(t2[3:])
	p1 = float(a + d)
	p2 = 0
	if 2 * d <= a:
		p2 = float(a)
	else:
		p2 = float(a / 2 + d)
	print(p1, p2)


t = int(input())
for i in range(t):
	(t11, t12) = map(int, input().split(':'))
	(t21, t22) = map(int, input().split(':'))
	dist = int(input())
	time_difference = (t11 - t21) * 60 + (t12 - t22)
	t1 = float(dist + time_difference)
	if time_difference <= 2 * dist:
		t2 = float(time_difference + (2 * dist - time_difference) / 2)
	else:
		t2 = float(time_difference)
	t1 = '{:.1f}'.format(t1)
	t2 = '{:.1f}'.format(t2)
	print(t1, end=' ')
	print(t2)


def sol(dist, time1, time2):
	t1 = int(time1[0]) * 60 + int(time1[1])
	t2 = int(time2[0]) * 60 + int(time2[1])
	waiting = t1 - t2
	print(waiting + dist / 1, end=' ')
	if 2 * dist < waiting:
		print(waiting / 1)
	else:
		remdist = (2 * dist - waiting) / 2
		print(waiting + remdist)
t = int(input())
while t:
	time1 = input().split(':')
	time2 = input().split(':')
	dist = int(input())
	sol(dist, time1, time2)
	t -= 1


from datetime import datetime
for _ in range(int(input())):
	t1 = input()
	t2 = input()
	d = int(input())
	time_format = '%H:%M'
	t1 = datetime.strptime(t1, time_format)
	t2 = datetime.strptime(t2, time_format)
	diff = (t1 - t2).seconds / 60
	print(diff + d, end=' ')
	if diff >= d * 2:
		print(diff)
	else:
		print(diff / 2 + d)


for i in range(int(input())):
	t1 = input()
	t2 = input()
	d = int(input())
	h = int(t1[:2]) - int(t2[:2])
	m = int(t1[3:]) - int(t2[3:])
	a = h * 60 + m
	a1 = a + d
	req = d * 2
	if req <= a:
		a2 = a
	else:
		a2 = a + (req - a) / 2
	print('{:.1f}'.format(a1), end=' ')
	print('{:.1f}'.format(a2))


T = int(input())
for i in range(0, T):
	c = input()
	g = input()
	dis = int(input())
	c = list(c)
	g = list(g)
	c = int(c[0] + c[1]) * 60 + int(c[3] + c[4])
	g = int(g[0] + g[1]) * 60 + int(g[3] + g[4])
	diff = c - g
	aa = diff + dis
	b = max(diff, 2 * dis)
	if b == diff:
		print(aa / 1, b / 1)
	else:
		print(aa / 1, diff + (2 * dis - diff) / 2)


for _ in range(int(input())):
	time1 = [int(s) for s in input().split(':')]
	time2 = [int(s) for s in input().split(':')]
	time = (time1[0] - time2[0]) * 60 + time1[1] - time2[1]
	dist = int(input())
	print(f'{time + dist}.0 ', end='')
	if time > 2 * dist:
		print(f'{time}.0')
	else:
		print(f'{dist + time / 2}')


for _ in range(int(input())):
	(h1, m1) = map(int, input().split(':'))
	(h2, m2) = map(int, input().split(':'))
	dist = int(input())
	ans = []
	diff = (h1 - h2) * 60 + (m1 - m2)
	ans.append(float(diff + dist))
	if 2 * dist <= diff:
		ans.append(diff)
	else:
		temp = diff + (2 * dist - diff) / 2
		ans.append(temp)
	print('{:.1f}'.format(ans[0]), end=' ')
	print('{:.1f}'.format(ans[1]))


def solve(ts1, ts2, dist):
	t1 = int(ts1[:2]) * 60 + int(ts1[3:])
	t2 = int(ts2[:2]) * 60 + int(ts2[3:])
	time1 = t1 - t2 + dist
	time2 = t1 - t2 if dist * 2 <= t1 - t2 else (t1 - t2) / 2 + dist
	print('{:.1f}'.format(time1), end=' ')
	print('{:.1f}'.format(time2))
for _ in range(int(input())):
	ts1 = input()
	ts2 = input()
	dist = int(input())
	solve(ts1, ts2, dist)


for _ in range(int(input())):
	t1 = input().split(':')
	t2 = input().split(':')
	dist = float(input())
	d1 = float((int(t1[0]) - int(t2[0])) * 60)
	d2 = float(int(t1[1]) - int(t2[1]))
	x = d1 + d2 + dist
	if 2 * dist <= d1 + d2:
		y = d1 + d2
	else:
		y = (d1 + d2) / 2 + dist
	print(x, y)


for _ in range(int(input())):
	(h1, m1) = (int(i) for i in input().split(':'))
	(h2, m2) = (int(i) for i in input().split(':'))
	td = int(input())
	t1 = h1 * 60 + m1
	t2 = h2 * 60 + m2
	t21 = t1 - t2
	ans1 = t21 + td
	ans2 = t21 if 2 * td <= t21 else t21 / 2 + td
	print(f'{ans1:.1f} {ans2:.1f}')


for _ in range(int(input())):
	time1 = list(map(int, input().split(':')))
	time1 = time1[0] * 60 + time1[1]
	time2 = list(map(int, input().split(':')))
	time2 = time2[0] * 60 + time2[1]
	delta = float(time1 - time2)
	dist = float(input())
	if 2 * dist < delta:
		print(round(dist + delta, 1), round(delta, 1))
	else:
		print(round(dist + delta, 1), round(dist + delta / 2, 1))


for _ in range(int(input())):
	(t1, t2) = (list(map(int, input().split(':'))), list(map(int, input().split(':'))))
	d = int(input())
	k = 60 * (t1[0] - t2[0] - 1) + (60 - t2[1] + t1[1])
	if k / 2 + d < 2 * d:
		print(format(k + d, '.1f'), format(k / 2 + d, '.1f'))
	else:
		print(format(k + d, '.1f'), format(k, '.1f'))


t = int(input())
for i in range(t):
	t1 = [int(x) for x in input().split(':')]
	t2 = [int(x) for x in input().split(':')]
	dist = int(input())
	a1 = t1[0] * 60 + t1[1]
	a2 = t2[0] * 60 + t2[1]
	diff = a1 - a2
	print('%.1f' % float(diff + dist), end=' ')
	if 2 * dist <= diff:
		print('%.1f' % float(diff))
	else:
		print('%.1f' % (diff / 2 + dist))


tst = int(input())
for i in range(tst):
	a = input()
	b = input()
	d = int(input())
	t1 = int(a[0] + a[1]) * 60 + int(a[3] + a[4])
	t2 = int(b[0] + b[1]) * 60 + int(b[3] + b[4])
	a1 = float(t1 - t2 + d)
	if 2 * d <= t1 - t2:
		a2 = t1 - t2
	elif t1 - t2 < 2 * d:
		a2 = (t1 - t2 + d * 2) / 2
	print(a1, float(a2))


for _ in range(int(input())):
	t1 = list(map(int, input().split(':')))
	t2 = list(map(int, input().split(':')))
	d = int(input())
	if int(t1[1]) >= int(t2[1]):
		h = abs(int(t1[0]) - int(t2[0])) * 60
		m = abs(int(t1[1]) - int(t2[1]))
	else:
		h = abs(int(t1[0]) - int(t2[0])) * 60 - 60
		m = abs(60 + int(t1[1]) - int(t2[1]))
	print('%.1f' % (h + m + d), end=' ')
	print('%.1f' % max(h + m, h + m + (2 * d - h - m) / 2))


for _ in range(int(input())):
	(gh, gm) = map(int, input().split(':'))
	(bh, bm) = map(int, input().split(':'))
	dis = float(input())
	normalwait = 60 * (gh - bh) + (gm - bm)
	wait = normalwait + dis
	if 2 * dis <= normalwait:
		call = normalwait
	else:
		call = normalwait + (dis - normalwait) + normalwait / 2
	print(wait, call + 0.0)


T = int(input())
for _ in range(T):
	T1 = input().split(':')
	T2 = input().split(':')
	d = float(input())
	t1 = float(T1[0]) * 60 + float(T1[1])
	t2 = float(T2[0]) * 60 + float(T2[1])
	print(t1 - t2 + d, end=' ')
	if t1 - t2 >= 2 * d:
		print(t1 - t2)
	else:
		print(d + (t1 - t2) / 2)


for i in range(int(input())):
	gf_bus = 0
	st1 = input()
	st2 = input()
	bus_home = int(input())
	bus_home = float(bus_home)
	hour1 = int(st1[:2])
	hour2 = int(st2[:2])
	min1 = int(st1[3:])
	min2 = int(st2[3:])
	if hour1 == hour2:
		gf_bus = float(min1 - min2)
	elif min1 >= min2:
		gf_bus = float((hour1 - hour2) * 60 + (min1 - min2))
	else:
		gf_bus = float((hour1 - hour2 - 1) * 60 + (60 - min2) + min1)
	final_answer = str(gf_bus + bus_home) + ' '
	if gf_bus > 2 * bus_home:
		final_answer += str(gf_bus)
	else:
		final_answer += str(float((gf_bus + bus_home + bus_home) / 2))
	print(final_answer)