Given a time in $12$-hour AM/PM format, convert it to military (24-hour) time.  

Note: 
- 12:00:00AM on a 12-hour clock is 00:00:00 on a 24-hour clock. 

- 12:00:00PM on a 12-hour clock is 12:00:00 on a 24-hour clock.  

Example  

$\textbf{s}=\textbf{'12:01:00PM'}$   

Return '12:01:00'.

$\mathbf{s}=\text{'12:01:00AM'}$   

Return '00:01:00'.

Function Description  

Complete the timeConversion function in the editor below.  It should return a new string representing the input time in 24 hour format.  

timeConversion has the following parameter(s):

string s: a time in $12$ hour format  

Returns

string: the time in $24$ hour format

Input Format

A single string $\boldsymbol{\mathrm{~S~}}$ that represents a time in $12$-hour clock format (i.e.: $\textbf{hh:mm:ssAM}$ or $\textbf{hh:mm:ssPM}$).

Constraints

All input times are valid

Sample Input 0
07:05:45PM

Sample Output 0
19:05:45

Difficulty: EASY

Starter code:

Solutions:
ins = input().strip()
is_pm = ins[-2:].lower() == 'pm'
time_list = list(map(int, ins[:-2].split(':')))
if is_pm and time_list[0] < 12:
	time_list[0] += 12
if not is_pm and time_list[0] == 12:
	time_list[0] = 0
print(':'.join(map(lambda x: str(x).rjust(2, '0'), time_list)))


a = input()
b = a[8:10]
if a[0:2] == '12' and a[8:10] == 'PM':
	print(a[0:8])
elif a[0:2] == '12' and a[8:10] == 'AM':
	num2 = a[2:8]
	num1 = '00'
	print(num1 + num2)
elif b == 'PM':
	num1 = a[0:2]
	num2 = a[2:8]
	num3 = str(int(num1) + 12)
	print(num3 + num2)
else:
	print(a[0:8])


def convert(time):
	am_pm = time[-2:]
	time = time[:-2]
	if am_pm.lower() == 'am':
		time_split = list(time)
		hour = time_split[0] + time_split[1]
		if hour == '12':
			hour = '00'
			return hour + time[2:]
		return time
	else:
		time_split = list(time)
		hour = time_split[0] + time_split[1]
		if hour == '12':
			return time
		hour = str(int(hour) + 12)
		return hour + time[2:]
time = input()
print(convert(time))


time = input()
if time[-2:] == 'AM':
	if time[:2] == '12':
		print('00' + time[2:-2])
	else:
		print(time[:-2])
else:
	h = int(time[:2])
	if h < 12:
		h += 12
	print(str(h) + time[2:-2])


a = input()
print('%02d' % (int(a[:2]) % 12 + int(a[-2] == 'P') * 12) + a[2:-2])


time = input().split(':')
(hour, minute, second, ampm) = (int(time[0]), time[1], time[2][:2], time[2][2:])
if ampm == 'PM' and hour == 12:
	pass
elif ampm == 'PM':
	hour += 12
elif ampm == 'AM' and hour == 12:
	hour = 0
elif ampm == 'AM':
	pass
print(str(hour).zfill(2) + ':' + minute + ':' + second)


s = input()
if s[-2] == 'P':
	if s[0:2] == '12':
		print(s[:-2])
	else:
		w = int(s[0:2])
		w = str(w + 12)
		print(w + s[2:-2])
elif s[0:2] == '12':
	print('00' + s[2:-2])
else:
	print(s[:-2])


t = list(input().split(':'))
if t[0] == '12':
	t[0] = '00'
if t[2][-2:] == 'PM':
	t[0] = str(int(t[0]) + 12)
t[2] = t[2][:-2]
print(':'.join(t))


time = input().strip().split(':')
if time[2][2] == 'A':
	if time[0] == '12':
		time[0] = '00'
	time[2] = time[2][:2]
	print(':'.join(time))
else:
	if time[0] != '12':
		hr = int(time[0]) + 12
		time[0] = str(hr)
	time[2] = time[2][:2]
	print(':'.join(time))


a = input().split(':')
h = a[0]
m = a[1]
s = a[2]
hr = int(h)
if s[2] == 'A':
	if hr == 12:
		h = '00'
	print(h, m, s[0:2], sep=':')
else:
	if hr < 12:
		hr += 12
	print(hr, m, s[0:2], sep=':')


time = input()
if 'A' == time[8]:
	hour = int(time[:2])
	if 12 == hour:
		hour = 0
else:
	hour = int(time[:2]) + 12
	if 24 == hour:
		hour = 12
print('%02i' % hour + time[2:8])


from datetime import *
m = datetime.strptime(input(), '%I:%M:%S%p')
print(m.time())


s = input()
if s == '12:00:00AM':
	print('00:00:00')
elif s == '12:00:00PM':
	print('12:00:00')
elif s[0:2] == '12' and s[8:10] == 'AM':
	print('{:02}'.format(0), s[2:8], sep='')
elif s[8:10] == 'PM' and s[0:2] != '12':
	hours = int(s[0:2]) + 12
	print('{:02}'.format(hours), s[2:8], sep='')
else:
	print(s[0:8])


ampm = input()
oldlen = len(ampm)
if ampm[-2:] == 'PM' and ampm[:2] != '12':
	ampm = str(int(ampm[:2]) + 12) + ampm[2:]
if ampm[-2:] == 'AM' and ampm[:2] == '12':
	ampm = str(int(ampm[:2]) - 12) + ampm[2:]
print(ampm[:-2] if len(ampm) == oldlen else '0' + ampm[:-2])


a = input()
b = a.split(':')
if (b[2][2] == 'P') & (b[0] != '12'):
	print(str(12 + int(b[0])) + ':' + b[1] + ':' + b[2][0:2])
elif (b[2][2] == 'A') & (b[0] == '12'):
	print('00:' + b[1] + ':' + b[2][0:2])
else:
	print(b[0] + ':' + b[1] + ':' + b[2][0:2])


import sys
t = sys.stdin.read().split(':')
h = int(t[0][0]) * 10 + int(t[0][1])
if t[2][2] == 'P' and h != 12:
	h += 12
elif t[2][2] == 'A' and h == 12:
	h -= 12
h = str(h)
if len(h) < 2:
	h = '0' + h
output = ':'.join([h, t[1], t[2]])[0:8]
print(output)


inp = input()
a = inp[-2:]
if a == 'AM':
	out = ''
	if inp[:2] == '12':
		out = '00' + inp[2:8]
		print(out)
	else:
		print(inp[0:8])
elif inp[:2] == '12':
	print(inp[0:8])
else:
	out = int(inp[:2]) + 12
	k = str(out) + inp[2:8]
	print(k)


hour_time = input()
hour = int(hour_time[0:2])
if hour_time[8:] == 'PM' and hour != 12:
	hour += 12
if hour_time[8:] == 'AM' and hour == 12:
	hour = 0
print('{0:02d}:{1}:{2}'.format(hour, hour_time[3:5], hour_time[6:8]))


(h, m, s) = input().split(':')
if s[2:] == 'PM':
	if h != '12':
		print('%d:%s:%s' % (int(h) + 12, m, s[:2]))
	else:
		print('%s:%s:%s' % (h, m, s[:2]))
elif h == '12':
	print('%s:%s:%s' % ('00', m, s[:2]))
else:
	print('%s:%s:%s' % (h, m, s[:2]))


st = input()
if st[-2] == 'P':
	if st[0:2] == '12':
		result = '12' + st[2:8]
	else:
		result = str(int(st[0:2]) + 12) + st[2:8]
elif st[0:2] == '12':
	result = '00' + st[2:8]
else:
	result = st[0:8]
print(result)


inp = str(input())
(hr, min, sec, m) = (int(inp[:2]), int(inp[3:5]), int(inp[6:8]), inp[8:11])
if m == 'PM':
	if hr < 12:
		hr = hr + 12
elif m == 'AM':
	if hr == 12:
		hr = 0
print('%02d:%02d:%02d' % (hr, min, sec))


(a, b, c) = list(input().split(':'))
(c, d) = (c[:2], c[-2:])
a = int(a)
if a == 12:
	if d == 'AM':
		a = 0
elif d == 'PM':
	a = (a + 12) % 24
print('{:02d}'.format(a), end='')
print(':' + b + ':' + c)


time_ampm = input().split(':')
hh = int(time_ampm[0])
mm = int(time_ampm[1])
ss_period = time_ampm[2]
ss = int(ss_period[0:2])
period = ss_period[2:5]
if period == 'PM':
	if hh == 12:
		hh = 12
	else:
		hh = (12 + hh) % 24
elif hh == 12:
	hh = 0
time_24 = str('{0:02d}'.format(hh)) + ':' + str('{0:02d}'.format(mm)) + ':' + str('{0:02d}'.format(ss))
print(time_24)


time24 = []
(hours, minutes, etc) = input().split(':')
seconds = etc[:2]
ampm = etc[2].lower()
if ampm == 'p' and hours != '12':
	hours = int(hours)
	hours = hours + 12
	hours = str(hours)
elif ampm == 'a' and hours == '12':
	hours = '00'
time24.extend([hours, minutes, seconds])
print(':'.join(time24))


time = input()
print('0' * (2 - len(str(int(time[:2]) % 12))) + str(int(time[:2]) % 12) + time[2:-2] if time[-2:] == 'AM' else str(int(time[:2]) % 12 + 12) + time[2:-2])


a = input().split(':')
h = int(a[0])
m = int(a[1])
s = int(a[2][:2])
if a[2][2:] == 'AM':
	print('{:02}:{:02}:{:02}'.format(h % 12, m, s))
else:
	print('{:02}:{:02}:{:02}'.format(h % 12 + 12, m, s))


timeStr = input()
meridiem = timeStr[-2:]
(h, m, s) = timeStr[:-2].split(':')
if meridiem == 'AM':
	if h == '12':
		h = '00'
	print(h + ':' + m + ':' + s)
else:
	if h != '12':
		h = str(int(h) + 12)
	print(h + ':' + m + ':' + s)


import os
import sys
import re

def convertTime(time):
	string = '(\\d{2}):\\d{2}:\\d{2}(\\w{2})'
	match = re.findall(string, time)
	if match:
		hours = int(match[0][0])
		p = match[0][1]
		if p == 'PM':
			if hours != 12:
				hours += 12
				newTime = str(hours) + time[2:-2]
			else:
				newTime = time[:-2]
		elif hours == 12:
			newTime = '00' + time[2:-2]
		else:
			newTime = time[:-2]
		print(newTime)

def main():
	time = input()
	convertTime(time)
main()


time_12 = input()
ampm = time_12[-2:]
hour_12 = int(time_12[:2])
hour_24 = hour_12
if ampm == 'PM' and hour_12 < 12 or (ampm == 'AM' and hour_12 == 12):
	hour_24 += 12
	hour_24 = hour_24 % 24
time_24 = '{:02}{}'.format(hour_24, time_12[2:-2])
print(time_24)


time = input()
tod = time[-2:]
time = time[:-2]
if tod == 'AM':
	if time[:2] == '12':
		print('00' + time[-6:])
	else:
		print(time)
elif time[:2] == '12':
	print('12' + time[-6:])
else:
	(hh, mm, ss) = time.split(':')
	hh = int(hh) + 12
	print(str(hh) + ':' + mm + ':' + ss)


k = input()
h = k[0:2]
m = k[3:5]
s = k[6:8]
t = k[8:]
if t == 'AM':
	if h == '12':
		h = '00'
	print(h + ':' + m + ':' + s)
else:
	if h != '12':
		h = int(h) + 12
	print(str(h) + ':' + m + ':' + s)


timeline = input()
(HH, MM, SS) = [int(t) for t in timeline[:-2].split(':')]
is_pm = timeline[-2:] == 'PM'
HH_adj = 12 if is_pm else 0
new_HH = HH % 12 + HH_adj
print('{:02}:{:02}:{:02}'.format(new_HH, MM, SS))


tString = input()
if 'AM' == tString[8:10]:
	if '12' == tString[0:2]:
		print('00' + tString[2:8])
	else:
		print(tString[0:8])
elif '12' == tString[0:2]:
	print(tString[0:8])
else:
	h = int(tString[0:2]) + 12
	print(str(h) + tString[2:8])


h = input()
if h[0:2] == '12':
	if h[-2:] == 'AM':
		print('00' + h[2:-2])
	else:
		print(h[0:-2])
elif h[-2:] == 'PM':
	if h[0:2] == '12':
		print(h[0:-2])
	else:
		pm = str(int(h[0:2]) + 12)
		print(pm + h[2:-2])
else:
	print(h[0:-2])


input_time = input()
AMPM = input_time[-2:]
time_split = input_time[:-2].split(':')
if AMPM == 'PM':
	if time_split[0] != '12':
		time_split[0] = str(int(time_split[0]) + 12)
elif time_split[0] == '12':
	time_split[0] = '00'
print(':'.join(time_split))


s = input()
ap = s[8]
s = s[:8]
a = [int(i) for i in s.split(':')]
if ap == 'P' and a[0] != 12:
	a[0] += 12
elif ap == 'A' and a[0] == 12:
	a[0] = 0
print('%02d:%02d:%02d' % (a[0], a[1], a[2]))


(h, m, s) = input().split(':')
if s.endswith('PM') and h != '12':
	h = str(int(h) + 12).format('{:00}')
elif s.endswith('AM') and h == '12':
	h = '00'
s = s.replace('PM', '').replace('AM', '')
print(':'.join([h, m, s]))


times = input().split(':')
if int(times[0]) == 12:
	times[0] = int(times[0]) - 12
if times[2][2:] == 'PM':
	times[0] = (int(times[0]) + 12) % 24
print('{0:02d}'.format(int(times[0])) + ':' + times[1] + ':' + times[2][0:2])


timeString = str(input())
timeArr = timeString.split(':')
(hour, minute, second, ampm) = (int(timeArr[0]), int(timeArr[1]), int(timeArr[2][0:2]), timeArr[2][2:])
if hour == 12 and ampm == 'AM':
	hour = 0
elif hour < 12 and ampm == 'PM':
	hour += 12
print('{0}:{1}:{2}'.format(str(hour).zfill(2), str(minute).zfill(2), str(second).zfill(2)))


AmPmFormat = input().split(':')
if AmPmFormat[2][2:4] == 'PM':
	if int(AmPmFormat[0]) > 0 and int(AmPmFormat[0]) != 12:
		AmPmFormat[0] = str(int(AmPmFormat[0]) + 12)
	AmPmFormat[2] = AmPmFormat[2].replace('PM', '')
elif AmPmFormat[2][2:4] == 'AM':
	if int(AmPmFormat[0]) == 12:
		AmPmFormat[0] = '00'
	AmPmFormat[2] = AmPmFormat[2].replace('AM', '')
print(':'.join(AmPmFormat))


time = input()
strhour = time[:2]
hour = int(strhour)
if time[8] == 'P':
	if hour < 12:
		hour += 12
	if hour < 10:
		strhour = '0' + str(hour)
	else:
		strhour = str(hour)
	print(strhour + time[2:8])
else:
	if strhour == '12':
		strhour = '00'
	print(strhour + time[2:8])


import datetime
print(datetime.datetime.strptime(input(), '%I:%M:%S%p').strftime('%H:%M:%S'))


n = input()
ap = n[8:]
hh = int(n[0:2])
mm = n[3:5]
ss = n[6:8]
if ap == 'AM':
	if hh == 12:
		hh = 0
		print('0' + str(hh) + ':' + mm + ':' + ss)
	elif hh < 10:
		print('0' + str(hh) + ':' + mm + ':' + ss)
	else:
		print(str(hh) + ':' + mm + ':' + ss)
elif hh == 12:
	print(str(hh) + ':' + mm + ':' + ss)
else:
	print(str(hh + 12) + ':' + mm + ':' + ss)


str_time = input().split(':')
hours = int(str_time[0])
if hours == 12:
	hours = 0
if str_time[2][2:4] == 'PM':
	hours += 12
print('{:02d}:{:s}:{:s}'.format(hours, str_time[1], str_time[2][0:2]))


import time
rawtime = input()
format = '%I:%M:%S%p'
print(time.strftime('%H:%M:%S', time.strptime(rawtime, format)))


case = input()
splitcase = case.split(':')
if case.endswith('AM') and splitcase[0] == '12':
	print('00:' + ':'.join(splitcase[1:]).replace('AM', ''))
elif case.endswith('AM'):
	print(case.replace('AM', ''))
elif case.endswith('PM') and splitcase[0] == '12':
	print(case.replace('PM', ''))
elif case.endswith('PM'):
	print(str(int(splitcase[0]) + 12) + ':' + ':'.join(splitcase[1:]).replace('PM', ''))


inputTime = input().split(':')
if str(inputTime[0]) == '12' and str(inputTime[2]).count('PM') == 1:
	inputTime[0] = '12'
	inputTime[2] = str(inputTime[2]).replace('PM', '')
elif str(inputTime[2]).count('PM') == 1:
	changeTime = int(inputTime[0]) + 12
	inputTime[0] = changeTime
	inputTime[2] = str(inputTime[2]).replace('PM', '')
elif str(inputTime[0]) == '12' and str(inputTime[2]).count('AM') == 1:
	inputTime[0] = '00'
	inputTime[2] = str(inputTime[2]).replace('AM', '')
else:
	inputTime[2] = str(inputTime[2]).replace('AM', '')
finalTime = str(inputTime[0]) + ':' + inputTime[1] + ':' + str(inputTime[2])
print(finalTime)


t = input()
last = ''
ap = t[8:10]
if ap == 'AM':
	if t[0:2] == '12':
		last = '00' + t[2:8]
	else:
		last = t[0:8]
elif t[0:2] != '12':
	last = str(12 + int(t[0:2])) + t[2:8]
else:
	last = t[0:8]
print(last)


a = input().split(':')
if a[2].find('AM') > 0:
	print(str(int(a[0]) % 12).zfill(2) + ':' + a[1] + ':' + a[2].split('AM')[0])
else:
	print(str(int(a[0]) % 12 + 12).zfill(2) + ':' + a[1] + ':' + a[2].split('PM')[0])


inp = input()
a = inp[-2:]
h = int(inp[:2])
if a == 'AM':
	if h != 12:
		print(inp[:-2])
	else:
		print('00' + inp[2:-2])
elif a == 'PM':
	if h != 12:
		h = (h + 12) % 24
	if h > 9:
		print(str(h) + inp[2:-2])
	else:
		print('0' + str(h) + inp[2:-2])


n = input()
amPm = 0
if n[8].upper() == 'P':
	if n[0:2] != '12':
		amPm = 12
elif n[0:2] == '12':
	amPm = -12
print('%02d%s' % ((int(n[0:2]) + amPm) % 24, n[2:8]))


s = list(input().split(':'))
ap = s[2][2:]
if ap == 'PM' and s[0] == '12':
	print('12:%s:%s' % (s[1], s[2][:-2]))
elif ap == 'PM':
	hh = int(s[0][0]) * 10 + int(s[0][1])
	hh += 12
	print('%d:%s:%s' % (hh, s[1], s[2][:-2]))
elif ap == 'AM' and s[0] == '12':
	print('00:%s:%s' % (s[1], s[2][:-2]))
elif len(s[2]) == 4:
	print('%s:%s:%s' % (s[0], s[1], s[2][:-2]))
else:
	print('%s:%s:%s' % (s[0], s[1], s[2]))


time = input()
hour = time[0:2]
minutes = time[3:5]
seconds = time[6:8]
if time[8:] == 'PM' and int(hour) < 12:
	hour = str(int(hour) + 12)
elif time[8:] == 'AM' and int(hour) == 12:
	hour = '00'
print('{0:s}:{1:s}:{2:s}'.format(hour, minutes, seconds))


import datetime
x = input()
x = datetime.datetime.strptime(x, '%I:%M:%S%p')
x = x.strftime('%H:%M:%S')
print(x)


(H, M, S) = input().split(':')
H = int(H)
if S[-2:].lower() == 'pm':
	if H < 12:
		H += 12
elif H == 12:
	H = 0
print(':'.join(('%02i' % int(x) for x in (H, M, S[:-2]))))


from datetime import datetime
in_date = datetime.strptime(input(), '%I:%M:%S%p')
print(datetime.strftime(in_date, '%H:%M:%S'))


currentTime = input()
isPM = currentTime[-2:] == 'PM'
currentTime = currentTime[:-2]
hour = int(currentTime[:2])
if hour == 12:
	if not isPM:
		currentTime = '00' + currentTime[2:]
elif isPM:
	currentTime = str(hour + 12) + currentTime[2:]
print(currentTime)


st = input()
if st[8:] == 'AM':
	if st[:2] == '12':
		print('00' + st[2:8])
	else:
		print(st[:8])
elif st[8:] == 'PM':
	if st[:2] == '12':
		print(st[:8])
	else:
		print(str(int(st[:2]) + 12) + st[2:8])
else:
	print('12:00:00')


st = input()
s = st.split(':')
if s[2][2] == 'A':
	if int(s[0]) == 12:
		print('00' + st[2:8])
	else:
		print(st[0:8])
elif int(s[0]) == 12:
	print(st[0:8])
else:
	cpy = ''
	cpy += str(12 + int(s[0]))
	cpy += ':'
	cpy += s[1]
	cpy += ':'
	cpy += s[2][0:2]
	print(cpy)


s = input()
m = s[-2:]
t = s[:-2]
h = int(s[:2])
if m == 'PM' and h != 12:
	h += 12
if m == 'AM' and h == 12:
	h = 0
h = str(h)
if len(h) == 1:
	h = '0' + h
t = h + t[2:]
print(t)


time = input().split(':')
hours = int(time[0])
minutes = time[1]
seconds = time[2][:2]
ap = time[2][2:]
if ap == 'PM' and hours != 12:
	hours += 12
elif ap == 'PM' and hours == 12:
	hours = 12
elif ap == 'AM' and hours == 12:
	hours = 0
if hours < 10:
	hourString = '0' + str(hours)
else:
	hourString = str(hours)
print(hourString + ':' + minutes + ':' + seconds)


tijdin = str(input())
letters = tijdin[8:10]
tijdlos = tijdin[0:8]
tijdele = [str(i) for i in tijdlos.split(':')]
if letters == 'PM' and tijdele[0] != '12':
	tijdele[0] = int(tijdele[0]) + 12
	tijdnieuw = ':'.join((str(e) for e in tijdele))
	print(tijdnieuw)
elif letters == 'AM' and tijdele[0] == '12':
	tijdele[0] = '00'
	tijdnieuw = ':'.join((str(e) for e in tijdele))
	print(tijdnieuw)
else:
	print(tijdlos)


def convertTime(h, m, s, t):
	hoursinint = int(h)
	if t == 'AM' and h == '12':
		hours = '00'
		return hours + ':' + m + ':' + s
	if t == 'PM' and hoursinint < 12:
		hoursinint += 12
		return repr(hoursinint) + ':' + m + ':' + s
	return h + ':' + m + ':' + s
time = input()
hours = time[0:2]
minutes = time[3:5]
seconds = time[6:8]
ampm = time[8:10]
print(convertTime(hours, minutes, seconds, ampm))


import sys
time = sys.stdin.readline()
t = list(map(int, time[0:8].split(':')))
if time[8] == 'A' or time[8] == 'a':
	day = 'am'
else:
	day = 'pm'
time = list(time[0:8])
if t[0] == 12 and day == 'am':
	time[0] = 0
	time[1] = 0
	for i in time:
		print(i, sep='', end='')
elif t[0] == 12 and day == 'pm' or day == 'am':
	for i in time:
		print(i, sep='', end='')
else:
	hr = t[0] + 12
	time[1] = int(hr % 10)
	hr /= 10
	time[0] = int(hr)
	for i in time:
		print(i, sep='', end='')


import re
bad = input()
spl = list(re.search('(^[0-9]+):([0-9]+):([0-9]+)(.*$)', bad).groups())
ap = spl.pop()
if ap == 'AM':
	if int(spl[0]) == 12:
		spl[0] = '00'
elif int(spl[0]) != 12:
	spl[0] = str(int(spl[0]) + 12).zfill(2)
print(':'.join(spl))


input_time = input()
(time, ampm) = (input_time[:-2], input_time[-2:])
(hours, mins, secs) = time.split(':')
hours = int(hours)
if ampm == 'PM':
	hours += 12
	hours = hours % 24
	if not hours:
		hours = '12'
elif ampm == 'AM' and hours < 10:
	hours = '0' + str(hours)
elif ampm == 'AM' and hours == 12:
	hours = '00'
print('{}:{}:{}'.format(hours, mins, secs))


line = list(input())
hh = int(line[0]) * 10 + int(line[1])
mm = int(line[3]) * 10 + int(line[4])
ss = int(line[6]) * 10 + int(line[7])
outline = ''
if len(line) > 8:
	if line[8] == 'A':
		if hh < 10:
			outline = outline + '0' + str(hh) + ':'
		else:
			if hh == 12:
				outline = outline + '0'
				hh = 0
			outline = outline + str(hh) + ':'
	elif hh < 12:
		outline = outline + str(hh + 12) + ':'
	else:
		outline = outline + str(hh) + ':'
if mm < 10:
	outline = outline + '0' + str(mm) + ':'
else:
	outline = outline + str(mm) + ':'
if ss < 10:
	outline = outline + '0' + str(ss)
else:
	outline = outline + str(ss)
print(outline)


import time
t = input().strip()

def convert_time(t):
	return time.strftime('%H:%M:%S', time.strptime(t, '%I:%M:%S%p'))
print(convert_time(t))


from datetime import datetime
print(datetime.strptime(input(), '%I:%M:%S%p').strftime('%H:%M:%S'))


line = input()
hour = line[:2]
end = line[-2:]
if hour == '12' and end == 'AM':
	hour = '00'
elif hour != '12' and end == 'PM':
	hour = str(int(hour) + 12)
print(hour + line[2:-2])


am_pm = input()
am_pm_parts = am_pm.split(':')
am_pm_parts[-1] = am_pm_parts[-1][:2]
if am_pm[-2:] == 'PM':
	if am_pm_parts[0] != '12':
		am_pm_parts[0] = str(int(am_pm_parts[0]) + 12)
elif am_pm[-2:] == 'AM':
	if am_pm_parts[0] == '12':
		am_pm_parts[0] = '00'
print(':'.join(am_pm_parts))


t = input()
b = t.split(':')
pastNoon = b[2][2:] == 'PM'
h = int(b[0]) % 12 + (12 if pastNoon else 0)
m = int(b[1])
s = int(b[2][:2])
print('%02d:%02d:%02d' % (h, m, s))


def to_int(l):
	n = 0
	for i in l:
		n = n * 10 + int(i)
	return n
s = list(input())
if s[-2] == 'A':
	x = to_int(s[:2])
	if x == 12:
		s[:2] = ['0', '0']
	print(''.join(s[:-2]))
else:
	x = to_int(s[:2])
	if x < 12:
		x += 12
		s[:2] = list(str(x))
	print(''.join(s[:-2]))


i_time = input()
if i_time == '12:00:00AM':
	print('00:00:00')
	exit()
if i_time == '12:00:00PM':
	print('12:00:00')
	exit()
if i_time[8] == 'A':
	hour = int(i_time[:2])
	if hour == 12:
		hour = 0
	hour = '{:02.0f}'.format(hour)
	print(str(hour) + i_time[2:8])
else:
	hour = int(i_time[:2]) + 12
	if hour == 24:
		hour = 12
	hour = '{:02.0f}'.format(hour)
	print(str(hour) + i_time[2:8])


time = input()
time_arr = time.split(':')
if time_arr[2][-2:] == 'PM':
	if int(time_arr[0]) != 12:
		time_arr[0] = int(time_arr[0]) + 12
elif int(time_arr[0]) == 12:
	time_arr[0] = '00'
print('{0[0]}:{0[1]}:{1}'.format(time_arr, time_arr[2][:2]))


from datetime import datetime
t = datetime.strptime(input(), '%I:%M:%S%p')
print(t.strftime('%H:%M:%S'))


from datetime import datetime
original = input()
time = datetime.strptime(original, '%I:%M:%S%p')
print(time.strftime('%H:%M:%S'))


(h, m, sampm) = input().split(':')
ampm = sampm[2:4]
s = sampm[0:2]
if ampm == 'AM':
	if h == '12':
		print('00', end=':')
	else:
		print(h, end=':')
	print(m, end=':')
	print(s, end='\n')
elif ampm == 'PM':
	if h == '12':
		print(h, end=':')
	else:
		hr = int(h) + 12
		print(hr, end=':')
	print(m, end=':')
	print(s, end='\n')


import re
time = input().split(':')
sec = time[2]
GM = re.split('(\\d+)', sec)
if GM[2] == 'PM':
	if time[0] == '12':
		print(time[0] + ':' + time[1] + ':' + GM[1])
	else:
		hh = int(time[0])
		hh = hh + 12
		time_string = str(hh) + ':' + time[1] + ':' + GM[1]
		print(time_string)
elif time[0] == '12':
	print('00' + ':' + time[1] + ':' + GM[1])
else:
	print(time[0] + ':' + time[1] + ':' + GM[1])


in_data = input()
time_stamp = in_data[:8]
modifier = in_data[8:]
hours = int(time_stamp[:2])
rest = time_stamp[2:]
if hours == 12 and modifier == 'AM':
	print('00' + rest)
elif modifier == 'AM':
	print(time_stamp)
elif hours == 12 and modifier == 'PM':
	print(time_stamp)
else:
	print(str(hours + 12) + rest)


time = input().split(':')
if 'PM' in time[2]:
	hh = int(time[0])
	if hh != 12:
		time[0] = str(hh + 12)
		if time[0] == '24':
			time[0] = '00'
elif time[0] == '12':
	time[0] = '00'
print(':'.join(time)[:-2])


from datetime import datetime
us_time = input()
print(datetime.strptime(us_time, '%I:%M:%S%p').strftime('%H:%M:%S'))


time_12_hour = input()
time = time_12_hour[:8]
am_pm = time_12_hour[8:]
hour = int(time_12_hour[:2])
if am_pm == 'PM':
	if hour < 12:
		hour += 12
elif hour == 12:
	hour = 0
time = str(hour).rjust(2, '0') + time[2:]
print(time)


time = input()
am_pm = time[-2:]
if am_pm == 'PM' and time[:2] != '12':
	time = '{:02}'.format(int(time[:2]) + 12) + time[2:]
elif am_pm == 'AM' and time[:2] == '12':
	time = '00' + time[2:]
print(time[:-2])


time = input()
if time[-2] == 'A':
	hour = int(time[:2])
	if hour == 12:
		print('00' + time[2:-2])
	else:
		print(time[:-2])
elif time[-2] == 'P':
	hour = int(time[:2])
	if hour == 12:
		print(time[:-2])
	else:
		print(str(hour + 12) + time[2:-2])


time = input()
new_time = time
if time[-2] == 'P' and time[0:2] != '12':
	hour = int(time[0:2])
	hour += 12
	new_time = str(hour) + new_time[2:]
elif time[-2] == 'A' and time[0:2] == '12':
	new_time = '00' + new_time[2:]
print(new_time[:-2])


s = input()
if s.endswith('PM'):
	x = s[:-2]
	(h, m, s) = list(map(int, x.split(':')))
	if h != 12:
		h = h + 12
	print('%02d:%02d:%02d' % (h, m, s))
else:
	x = s[:-2]
	(h, m, s) = list(map(int, x.split(':')))
	if h == 12:
		h = 0
	print('%02d:%02d:%02d' % (h, m, s))


import sys
S = sys.stdin.readline().strip()
PM = S.endswith('PM')
(H, M, S) = list(map(int, S[:-2].split(':')))
if H == 12 and (not PM):
	print('%02d:%02d:%02d' % (0, M, S))
elif H < 12 and PM:
	print('%02d:%02d:%02d' % (H + 12, M, S))
else:
	print('%02d:%02d:%02d' % (H, M, S))


st = input()
if st[-2] == 'A':
	hour = int(st[:2])
	if hour != 12:
		print(st[:-2])
	else:
		hour = '00'
		print(hour + st[2:-2])
elif st[-2] == 'P':
	hour = int(st[:2])
	hour += 12
	if hour != 24:
		print(str(hour) + st[2:-2])
	else:
		print(st[:-2])
else:
	print('12:00:00')


t = input()
n = int(t[0] + t[1])
if t[len(t) - 2] == 'A' and n != 12 or (t[len(t) - 2] == 'P' and n == 12):
	for i in range(len(t) - 2):
		print(t[i], end='')
else:
	n += 12
	if n == 24:
		n = '00'
	elif n < 10:
		n = '0' + str(n)
	print(str(n), end='')
	for i in range(2, len(t) - 2):
		print(t[i], end='')


inputTime = input()
isPm = inputTime[8:10] == 'PM'
hourStr = inputTime[0:2]
minuteStr = inputTime[3:5]
secondStr = inputTime[6:8]
if isPm:
	if hourStr == '12':
		hourStr == 12
	else:
		hourStr = int(hourStr) + 12
elif hourStr == '12':
	hourStr = '00'
print('%s:%s:%s' % (hourStr, minuteStr, secondStr))


x = input().split(':')
if x[0] != '12' and x[-1].endswith('PM'):
	x[0] = str((int(x[0]) + 12) % 24)
	if len(x[0]) == 1:
		x[0] = '0' + x[0]
if x[0] == '12' and x[-1].endswith('AM'):
	x[0] = '00'
x[-1] = x[-1].replace('AM', '').replace('PM', '')
print(':'.join(x[0:len(x)]))


string = input()
h = int(string[0:2])
m = string[3:5]
s = string[6:8]
ampm = string[8:]
if h == 12:
	h = 0
if ampm == 'PM':
	h = h + 12
h = str(h)
if len(h) == 1:
	h = '0' + h
print(':'.join([h, m, s]))


i = str(input())
j = int(i[0:2]) % 12 if i[8] == 'A' else (int(i[0:2]) + 12) % 24 if int(i[0:2]) < 12 else int(i[0:2])
print('{0:02d}'.format(j), end='')
print(i[2:-2])


import os
import sys
import re

def converteTempo(time):
	string = '(\\d{2}):\\d{2}:\\d{2}(\\w{2})'
	match = re.findall(string, time)
	if match:
		hours = int(match[0][0])
		p = match[0][1]
		if p == 'PM':
			if hours != 12:
				hours += 12
				newTime = str(hours) + time[2:-2]
			else:
				newTime = time[:-2]
		elif hours == 12:
			newTime = '00' + time[2:-2]
		else:
			newTime = time[:-2]
		print(newTime)

def main():
	time = input()
	converteTempo(time)
main()


s = input().split(':')
h = int(s[0])
m = int(s[1])
sec = int(s[2][0:2])
ampm = s[2][2:]
if ampm == 'PM' and h != 12:
	h = h + 12
elif ampm == 'AM' and h == 12:
	h = 0
print('%02d:%02d:%02d' % (h, m, sec))


time = input()
newtime = time[:-2]
if time[-2:] == 'PM' and time[:2] != '12':
	newhour = int(time[:2]) + 12
	newtime = str(newhour) + time[2:-2]
if time[-2:] == 'AM' and time[:2] == '12':
	newhour = '00'
	newtime = newhour + time[2:-2]
print(newtime)