Given the time in numerals we may convert it into words, as shown below:  

$\begin{array}{l}5.00\rightarrow\:five \quad o'clock\\
5.01\rightarrow\:one\quad minute \quad past\quad five\\ 
5.10\rightarrow\:ten\quad minutes\quad past\quad five\\ 
5.15\rightarrow\:quarter\quad past\quad five\\ 5.30\rightarrow\:half\quad past\quad five\\ 5.40\rightarrow\:thenty\quad minutes\quad to\quad six\\ 
5.45\rightarrow\:quarter\quad to\quad six\\ 5.47\rightarrow\:thirteen\quad mimutes\quad to\quad six\\ 5.28\rightarrow\:twenty\quad eight\quad minutes\quad past\quad five\end{array}$


At $minutes=0$, use o' clock.  For $1\leq minutes\leq30$, use past, and for $30<minutes$ use to.  Note the space between the apostrophe and clock in o' clock.  Write a program which prints the time in words for the input given in the format described.  

Function Description  

Complete the timeInWords function in the editor below.  

timeInWords has the following parameter(s):  

int h: the hour of the day  
int m: the minutes after the hour  

Returns  

string: a time string as described  

Input Format

The first line contains $\mbox{h}$, the hours portion 
The second line contains $m$, the minutes portion  

Constraints

$1\leq h\leq12$  
$0\leq m<60$

Sample Input 0
5
47

Sample Output 0
thirteen minutes to six

Sample Input 1
3
00

Sample Output 1
three o' clock

Sample Input 2
7
15

Sample Output 2
quarter past seven

Source: hackerrank | Difficulty: MEDIUM
Tags: Implementation


Solutions:
ones = 'one two three four five six seven eight nine'.split(' ')

def num_to_word(x):
	if x < 10:
		return ones[x - 1]
	if x == 10:
		return 'ten'
	if x < 20:
		return 'eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen'.split(' ')[x - 11]
	ten = x // 10
	one = x % 10
	tens = 'twenty thirty forty fifty'.split(' ')
	if one == 0:
		return tens[ten - 2]
	else:
		return tens[ten - 2] + ' ' + ones[one - 1]
h = int(input())
m = int(input())
if m > 30:
	if m == 59:
		print('one minute to %s' % num_to_word(h + 1 if h != 12 else 1))
	elif m == 45:
		print('quarter to %s' % num_to_word(h + 1 if h != 12 else 1))
	else:
		print('%s minutes to %s' % (num_to_word(60 - m), num_to_word(h + 1 if h != 12 else 1)))
elif m == 0:
	print("%s o' clock" % num_to_word(h))
elif m == 1:
	print('one minute past %s' % num_to_word(h))
elif m == 15:
	print('quarter past %s' % num_to_word(h))
elif m == 30:
	print('half past %s' % num_to_word(h))
else:
	print('%s minutes past %s' % (num_to_word(m), num_to_word(h)))


H = int(input())
M = int(input())
hours = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
minutes = ["o' clock", 'one minute', 'two minutes', 'three minutes', 'four minutes', 'five minutes', 'six minutes', 'seven minutes', 'eight minutes', 'nine minutes', 'ten minutes', 'eleven minutes', 'twelve minutes', 'thirteen minutes', 'fourteen minutes', 'quarter', 'sixteen minutes', 'seventeen minutes', 'eighteen minutes', 'nineteen minutes', 'twenty minutes', 'twenty one minutes', 'twenty two minutes', 'twenty three minutes', 'twenty four minutes', 'twenty five minutes', 'twenty six minutes', 'twenty seven minutes', 'twenty eight minutes', 'twenty nine minutes', 'half']
if H == 12 and M > 30:
	H = 0
if M > 30:
	print('{} to {}'.format(minutes[60 - M], hours[H]))
elif M == 0:
	print('{} {}'.format(hours[H - 1], minutes[M]))
else:
	print('{} past {}'.format(minutes[M], hours[H - 1]))


h = int(input())
m = int(input())
a = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
b = ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
c = ['twenty', 'thirty', 'forty', 'fifty']

def toword(n):
	if n <= 10:
		return a[n - 1]
	elif n < 20:
		return b[n - 11]
	elif n % 10 == 0:
		return c[n // 10 - 2]
	else:
		return c[n // 10 - 2] + ' ' + a[n % 10 - 1]

def myf(h, m):
	if m == 0:
		print(toword(h) + " o' clock")
	elif m == 15:
		print('quarter past ' + toword(h))
	elif m < 30:
		print(toword(m) + ' minutes past ' + toword(h))
	elif m == 30:
		print('half past ' + toword(h))
	elif m == 45:
		if h == 12:
			print('quarter to one')
		else:
			print('quarter to ' + toword(h + 1))
	elif m > 30:
		if h == 12:
			print(toword(60 - m) + ' minutes to one')
		else:
			print(toword(60 - m) + ' minutes to ' + toword(h + 1))
myf(h, m)


def time_words():
	w = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'half']
	h = int(input())
	m = int(input())
	op = ''
	if m == 0:
		op = w[h - 1] + " o' clock"
	elif m == 30:
		op = w[m - 1] + ' past ' + w[h - 1]
	elif m == 1:
		op = w[m - 1] + ' minute past ' + w[h - 1]
	elif m == 15:
		op = w[m - 1] + ' past ' + w[h - 1]
	elif m < 30:
		op = w[m - 1] + ' minutes past ' + w[h - 1]
	elif m == 45:
		op = 'quarter to ' + w[h]
	else:
		op = w[60 - m - 1] + ' minutes to ' + w[h]
	return op
print(time_words())


ONES = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
TEENS = ['thir', 'four', 'fif', 'six', 'seven', 'eight', 'nine']
OTHER = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty']

def num_to_word(number):
	if number < 13:
		return ONES[number]
	elif number < 20:
		return TEENS[number - 13] + 'teen'
	else:
		string = OTHER[int(number / 10)] + ' ' + ONES[number % 10]
		return string.strip()

def time_to_word(hour, minutes):
	if minutes == 0:
		return num_to_word(hour) + " o' clock"
	if minutes < 30:
		m = num_to_word(minutes) + ' minute'
		if minutes != 1:
			m += 's'
		if minutes == 15:
			m = 'quarter'
		return m + ' past ' + num_to_word(hour)
	elif minutes > 30:
		m = num_to_word(60 - minutes) + ' minutes'
		if 60 - minutes == 15:
			m = 'quarter'
		return m + ' to ' + num_to_word(hour + 1)
	else:
		return 'half past ' + num_to_word(hour)
h = int(input())
m = int(input())
print(time_to_word(h, m))


words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'half']
h = int(input())
m = int(input())
phrase = ''
hmod = (h - 1) % 12
if m == 0:
	phrase = words[hmod] + " o' clock"
elif m == 1:
	phrase = 'one minute past' + words[hmod]
elif m <= 30:
	if m == 15 or m == 30:
		phrase = words[m - 1] + ' past ' + words[hmod]
	else:
		phrase = words[m - 1] + ' minutes past ' + words[hmod]
elif m == 59:
	phrase = 'one minute to ' + words[(hmod + 1) % 12]
elif m > 30:
	if m != 45:
		phrase = words[60 - m - 1] + ' minutes to ' + words[(hmod + 1) % 12]
	else:
		phrase = words[60 - m - 1] + ' to ' + words[(hmod + 1) % 12]
print(phrase)


h = int(input())
m = int(input())

def numtoword(n):
	if n == 1:
		return 'one'
	if n == 2:
		return 'two'
	if n == 3:
		return 'three'
	if n == 4:
		return 'four'
	if n == 5:
		return 'five'
	if n == 6:
		return 'six'
	if n == 7:
		return 'seven'
	if n == 8:
		return 'eight'
	if n == 9:
		return 'nine'
	if n == 10:
		return 'ten'
	if n == 11:
		return 'eleven'
	if n == 12:
		return 'twelve'
	if n == 13:
		return 'thirteen'
	if n == 14:
		return 'fourteen'
	if n == 15:
		return 'quarter'
	if n == 16:
		return 'sixteen'
	if n == 17:
		return 'seventeen'
	if n == 18:
		return 'eighteen'
	if n == 19:
		return 'nineteen'
	if n == 20:
		return 'twenty'
	if n > 20:
		return 'twenty ' + numtoword(n - 20)

def prev(n):
	if n == 12:
		return 1
	else:
		return n + 1
if m == 0:
	print(numtoword(h) + " o' clock")
elif m % 15 == 0:
	if m == 15:
		print('quarter past ' + numtoword(h))
	elif m == 30:
		print('half past ' + numtoword(h))
	else:
		print('quarter to ' + numtoword(prev(h)))
elif m in [1, 59]:
	if m < 30:
		print('one minute past ' + numtoword(h))
	else:
		print('one minute to ' + numtoword(h))
elif m < 30:
	print(numtoword(m) + ' minutes past ' + numtoword(h))
else:
	print(numtoword(60 - m) + ' minutes to ' + numtoword(prev(h)))


h = int(input())
m = int(input())
words = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty fore', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine', 30: 'half'}
res = ''
if m == 0:
	res = words[h] + " o' clock"
elif m == 1:
	res = words[m] + ' minute past ' + words[h]
elif m == 59:
	res = words[60 - m] + ' minute to ' + words[h + 1]
elif m <= 30:
	if m % 15 == 0:
		res = words[m] + ' past ' + words[h]
	else:
		res = words[m] + ' minutes past ' + words[h]
elif m % 15 == 0:
	res = words[60 - m] + ' to ' + words[h + 1]
else:
	res = words[60 - m] + ' minutes to ' + words[h + 1]
print(res)


hours = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
minutes = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
H = input()
M = input()
h = int(H)
m = int(M)
if m <= 30:
	if m == 0:
		print(hours[h] + " o' clock")
	elif m == 30:
		print('half past ' + hours[h])
	elif m == 1:
		print('one minute past ' + hours[h])
	elif m == 15:
		print('quarter past ' + hours[h])
	else:
		print(minutes[m] + ' minutes past ' + hours[h])
elif m > 30:
	newM = 60 - m
	if newM == 1:
		print('one minute to ' + hours[h + 1])
	elif newM == 15:
		print('quarter to ' + hours[h + 1])
	else:
		print(minutes[newM] + ' minutes to ' + hours[h + 1])


HOURS = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
TENS_MINUTES = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
MINUTES_ONES_PLACE = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

def time_to_str(hour, minutes):
	if minutes == 0:
		return HOURS[hour - 1] + " o' clock "
	elif minutes == 1:
		return 'one minute past ' + HOURS[hour - 1 % 12]
	elif minutes == 59:
		return 'one minute to ' + HOURS[hour % 12]
	elif minutes == 30:
		return 'half past ' + HOURS[hour - 1 % 12]
	elif minutes == 45:
		return 'quarter to ' + HOURS[hour % 12]
	elif minutes == 15:
		return 'quarter past ' + HOURS[hour - 1 % 12]
	past_thirty = False
	if minutes > 30:
		minutes = 60 - minutes
		past_thirty = True
	hour = HOURS[hour % 12] if past_thirty else HOURS[hour - 1 % 12]
	minutes_digits = [int(minute) for minute in list(str(minutes))]
	adjective = 'to' if past_thirty else 'past'
	minutes_str = ''
	if minutes < 10:
		minutes_str = MINUTES_ONES_PLACE[minutes - 1]
	elif minutes < 20:
		minutes_str = TENS_MINUTES[minutes % 10]
	else:
		minutes_str = 'twenty'
		if minutes % 10 != 0:
			minutes_str += ' ' + MINUTES_ONES_PLACE[minutes_digits[1] - 1]
	return '{0} minutes {1} {2}'.format(minutes_str, adjective, hour)
hour = int(input())
minutes = int(input())
print(time_to_str(hour, minutes))


literalNumbers = ("o' clock", 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'thirty', 'thirty one', 'thirty two', 'thirty three', 'thirty four', 'thirty five', 'thirty six', 'thirty seven', 'thirty eight', 'thirty nine', 'forty', 'forty one', 'forty two', 'forty three', 'forty four', 'forty five', 'forty six', 'forty seven', 'forty eight', 'forty nine', 'fifty', 'fifty one', 'fifty two', 'fifty three', 'fifty four', 'fifty five', 'fifty six', 'fifty seven', 'fifty eight', 'fifty nine')
h = int(input())
m = int(input())
if m > 30:
	if m == 45:
		print('quarter to ' + literalNumbers[h + 1])
	else:
		m = 60 - m
		if m == 1:
			print(literalNumbers[m] + ' minute to ' + literalNumbers[h + 1])
		else:
			print(literalNumbers[m] + ' minutes to ' + literalNumbers[h + 1])
elif m == 30:
	print('half past ' + literalNumbers[h])
elif m == 15:
	print('quarter past ' + literalNumbers[h])
elif m == 0:
	print(literalNumbers[h] + ' ' + literalNumbers[m])
elif m == 1:
	print(literalNumbers[m] + ' minute past ' + literalNumbers[h])
else:
	print(literalNumbers[m] + ' minutes past ' + literalNumbers[h])


h = int(input())
m = int(input())
hours = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one']
minutes = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']
if m <= 30:
	if m == 0:
		print(hours[h] + " o' clock")
	elif m == 15:
		print('quarter past ' + hours[h])
	elif m == 30:
		print('half past ' + hours[h])
	elif m == 1:
		print(minutes[m] + ' minute past ' + hours[h])
	elif m > 20:
		print(minutes[20] + ' ' + minutes[m - 20] + ' minutes past ' + hours[h])
	else:
		print(minutes[m] + ' minutes past ' + hours[h])
elif m == 45:
	print('quarter to ' + hours[h + 1])
else:
	rem = 60 - m
	if rem > 20:
		print(minutes[20] + ' ' + minutes[rem - 20] + ' minutes to ' + hours[h + 1])
	elif rem == 1:
		print(minutes[rem] + ' minute to ' + hours[h + 1])
	else:
		print(minutes[rem] + ' minutes to ' + hours[h + 1])


x = int(input())
y = int(input())
t = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
if y == 0:
	print(t[x] + ' ' + "o' clock")
elif y == 1:
	print('one minute past ' + t[x])
elif 2 <= y <= 29 and y != 15:
	print(t[y] + ' minutes ' + 'past ' + t[x])
elif y == 15:
	print('quarter past ' + t[x])
elif y == 30:
	print('half past ' + t[x])
elif y == 45:
	if x == 12:
		print('quarter to one')
	else:
		print('quarter to ' + t[(x + 1) % 24])
elif x == 12:
	print(t[60 - y] + ' minutes to ' + 'one')
else:
	print(t[60 - y] + ' minutes to ' + t[(x + 1) % 24])


minutes = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'thirty']
hours = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
H = int(input())
M = int(input())
if M == 0:
	print(hours[H], "o' clock")
elif M == 15:
	print('quarter past', hours[H])
elif M == 30:
	print('half past', hours[H])
elif M == 45:
	if H == 12:
		print('quarter to', hours[1])
	else:
		print('quarter to', hours[H + 1])
elif M > 0 and M < 30:
	print(minutes[M], 'minutes past', hours[H])
elif M > 30 and M < 60:
	if H == 12:
		print(minutes[60 - M], 'minutes to', hours[1])
	else:
		print(minutes[60 - M], 'minutes to', hours[H + 1])


words = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine', 30: 'half'}
hours = int(input().strip())
mins = int(input().strip())
ans = ''
if mins == 0:
	ans = words[hours] + " o' clock"
else:
	past = 1
	if mins > 30:
		mins = 60 - mins
		past = 0
		if hours == 12:
			hours = 1
		else:
			hours = hours + 1
	ans = words[mins]
	if mins % 15 != 0:
		ans = ans + ' minutes'
	if past == 1:
		ans = ans + ' past'
	else:
		ans = ans + ' to'
	ans = ans + ' ' + words[hours]
print(ans)


numbers = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']

def english_time(h, m):
	minute = m
	hour = h - 1
	next_hour = h
	if h == 12:
		next_hour = 0
	if minute < 1:
		return numbers[hour] + " o' clock"
	elif minute == 1:
		return 'one minute past ' + numbers[hour]
	elif minute == 15:
		return 'quarter past ' + numbers[hour]
	elif minute == 30:
		return 'half past ' + numbers[hour]
	elif minute == 45:
		return 'quarter to ' + numbers[next_hour]
	elif minute == 59:
		return 'one minute to ' + numbers[next_hour]
	elif minute > 1 and minute < 15 or (minute > 15 and minute < 30):
		return numbers[minute - 1] + ' minutes past ' + numbers[hour]
	elif minute > 30 and minute < 45 or (minute > 45 and minute < 60):
		return numbers[60 - minute - 1] + ' minutes to ' + numbers[next_hour]
hour = int(input())
minute = int(input())
result = english_time(hour, minute)
print(result)


hour = int(input())
mins = int(input())
conversion_string = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine', 30: 'half'}
if mins == 0:
	print(conversion_string[hour] + " o' clock")
elif mins == 15 or mins == 30:
	print(conversion_string[mins] + ' past ' + conversion_string[hour])
elif mins < 30:
	print(conversion_string[mins] + ' minutes past ' + conversion_string[hour])
elif mins > 30:
	mins = 60 - mins
	if hour == 12:
		hour = 0
	if mins == 15:
		print(conversion_string[mins] + ' to ' + conversion_string[hour + 1])
	else:
		print(conversion_string[mins] + ' minutes to ' + conversion_string[hour + 1])


h = int(input())
m = int(input())
time_to_words = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine', 30: 'half'}
if m == 0:
	s = time_to_words[h] + " o' clock"
elif m > 30:
	m = 60 - m
	if m == 1:
		t = ' minute to '
	elif m == 15:
		t = ' to '
	else:
		t = ' minutes to '
	s = time_to_words[m] + t + time_to_words[h + 1]
else:
	if m == 1:
		t = ' minute past '
	elif m == 15 or m == 30:
		t = ' past '
	else:
		t = ' minutes past '
	s = time_to_words[m] + t + time_to_words[h]
print(s)


hour = int(input())
minutes = int(input())
hour += minutes // 60
minutes = minutes % 60
units = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
teens = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
tens = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']

def conv(time, hour=True):
	if hour:
		time = (time - 1) % 12 + 1
	if time < 10:
		return units[time]
	elif time < 20:
		return teens[time - 10]
	elif time % 10 == 0:
		return '{}'.format(tens[time // 10])
	else:
		return '{} {}'.format(tens[time // 10], units[time % 10])
if minutes == 0:
	print("{} o' clock".format(conv(hour)))
elif minutes == 15:
	print('quarter past {}'.format(conv(hour)))
elif minutes == 30:
	print('half past {}'.format(conv(hour)))
elif minutes == 45:
	print('quarter to {}'.format(conv(hour + 1)))
elif minutes < 30:
	print('{} minute{} past {}'.format(conv(minutes, False), 's' if minutes > 1 else '', conv(hour)))
else:
	print('{} minute{} to {}'.format(conv(60 - minutes, False), 's' if 60 - minutes > 1 else '', conv(hour + 1)))


numbers = ['_', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
hour = int(input())
minute = int(input())
if minute == 0:
	print("{hour} o' clock".format(hour=numbers[hour]))
elif minute == 15:
	print('quarter past {hour}'.format(hour=numbers[hour]))
elif minute < 30:
	print('{minute} {quantifier} past {hour}'.format(minute=numbers[minute], hour=numbers[hour], quantifier='minute' if minute == 1 else 'minutes'))
elif minute == 30:
	print('half past {hour}'.format(hour=numbers[hour]))
elif minute == 45:
	print('quarter to {hour}'.format(hour=numbers[hour + 1]))
elif minute > 30:
	print('{minute} {quantifier} to {hour}'.format(minute=numbers[60 - minute], hour=numbers[hour + 1], quantifier='minute' if minute == 59 else 'minutes'))


english = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
hour = int(input())
minute = int(input())
if minute == 0:
	print(english[hour] + " o' clock")
elif minute == 1:
	print('one minute past ' + english[hour])
elif minute == 59:
	print('one minute to ' + english[hour + 1])
elif minute == 30:
	print('half past ' + english[hour])
elif minute < 30:
	if minute == 15:
		print('quarter past ' + english[hour])
	else:
		print(english[minute] + ' minutes past ' + english[hour])
elif minute == 45:
	print('quarter to ' + english[hour + 1])
else:
	print(english[60 - minute] + ' minutes to ' + english[hour + 1])


wordnumber = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
tensdigit = {2: 'twenty'}

def wordOf(number):
	if number < 20:
		return wordnumber[number]
	first = tensdigit[number // 10]
	last = ' ' + wordnumber[number % 10] if number % 10 else ''
	return first + last

def wordTime(H, M):
	if M == 0:
		return wordOf(H) + " o' clock"
	if M > 30:
		H = H % 12 + 1
		M = 60 - M
		connector = ' to '
	else:
		connector = ' past '
	if M == 15:
		return 'quarter' + connector + wordOf(H)
	if M == 30:
		return 'half' + connector + wordOf(H)
	if M == 1:
		return wordOf(M) + ' minute' + connector + wordOf(H)
	return wordOf(M) + ' minutes' + connector + wordOf(H)
H = int(input())
M = int(input())
print(wordTime(H, M))


h = int(input())
m = int(input())
hd = dict(zip([x for x in range(1, 13)], 'one two three four five six seven eight nine ten eleven twelve'.split()))
md = dict(zip([x for x in range(1, 31)], 'one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,quarter,sixteen,seventeen,eighteen,nineteen,twenty,twenty one,twenty two,twenty three,twenty four,twenty five,twenty six,twenty seven,twenty eight,twenty nine,half'.split(',')))
if m == 0:
	print(hd[h], "o' clock")
elif m == 1:
	print(md[m], 'minute past', hd[h])
elif m == 15 or m == 30:
	print(md[m], 'past', hd[h])
elif m < 30:
	print(md[m], 'minutes past', hd[h])
elif m == 45:
	print(md[60 - m], 'to', hd[1 if h == 12 else h + 1])
elif m < 59:
	print(md[60 - m], 'minutes to', hd[1 if h == 12 else h + 1])
else:
	print(md[60 - m], 'minute to', hd[1 if h == 12 else h + 1])


D = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty'}

def main():
	H = int(input())
	M = int(input())
	timeInWords(H, M)

def timeInWords(H, M):
	if M == 0:
		print(numInWords(H) + " o' clock")
		return
	elif M < 30:
		if M == 15:
			print('quarter past ' + numInWords(H))
			return
		else:
			print(numInWords(M) + ' ' + minute(M) + ' past ' + numInWords(H))
			return
	elif M == 30:
		print('half past ' + numInWords(H))
	elif M == 45:
		print('quarter to ' + toHour(H))
		return
	else:
		print(numInWords(60 - M) + ' ' + minute(60 - M) + ' to ' + toHour(H))
		return

def toHour(n):
	if n == 12:
		return D[1]
	else:
		return D[n + 1]

def minute(n):
	if n == 1:
		return 'minute'
	else:
		return 'minutes'

def numInWords(n):
	if n <= 20:
		return D[n]
	else:
		return D[20] + ' ' + D[n - 20]
main()


from sys import stdin
H = int(stdin.readline())
M = int(stdin.readline())
NN = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
NM = ['twenty', 'thirty', 'forty', 'fifty']
NNN = [(b + ' ' + a).strip() for b in NM for a in [''] + NN[1:10]]
N = NN + NNN
HP1 = H % 12 + 1
if M == 0:
	s = N[H] + " o' clock"
elif M == 1:
	s = 'one minute past ' + N[H]
elif M == 15:
	s = 'quarter past ' + N[H]
elif 1 < M < 30:
	s = N[M] + ' minutes past ' + N[H]
elif M == 30:
	s = 'half past ' + N[H]
elif M == 45:
	s = 'quarter to ' + N[HP1]
else:
	s = N[60 - M] + ' minutes to ' + N[HP1]
print(s)


h = int(input())
m = int(input())
words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'thirty']
if m == 0:
	print("%s o' clock" % words[h - 1])
elif m == 1:
	print('one minute past %s' % words[h - 1])
elif m == 15:
	print('quarter past %s' % words[h - 1])
elif m <= 29:
	print('%s minutes past %s' % (words[m - 1], words[h - 1]))
elif m == 30:
	print('half past %s' % words[h - 1])
elif m == 45:
	if h == 12:
		h = 0
	print('quarter to %s' % words[h])
elif m == 59:
	if h == 12:
		h = 0
	print('one minute to %s' % words[h])
else:
	if h == 12:
		h = 0
	print('%s minutes to %s' % (words[60 - m - 1], words[h]))


__author__ = 'Joel Krebs'
import sys

def main():
	hour = int(sys.stdin.readline())
	minutes = int(sys.stdin.readline())
	sys.stdout.write(time_to_string(hour, minutes) + '\n')

def time_to_string(hour, minutes):
	if not minutes:
		return number_word(hour) + " o' clock"
	result = ''
	if minutes == 15 or minutes == 45:
		result += 'quarter'
	elif minutes == 30:
		result += 'half'
	elif minutes == 1 or minutes == 59:
		result += 'one minute'
	elif minutes > 30:
		result += number_word(60 - minutes) + ' minutes'
	else:
		result += number_word(minutes) + ' minutes'
	if minutes > 30:
		if hour == 12:
			result += ' to ' + number_word(1)
		else:
			result += ' to ' + number_word(hour + 1)
	else:
		result += ' past ' + number_word(hour)
	return result

def number_word(number):
	words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']
	if number <= 20:
		return words[number - 1]
	last_digit = number % 10
	return 'twenty ' + words[last_digit - 1]
main()


def int_to_word(i):
	units = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
	teens = ['', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
	tens = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty']
	if i < 10:
		return units[i]
	if i == 10:
		return tens[1]
	if i < 20:
		return teens[i - 10]
	i_str = str(i)
	n_digits = len(i_str)
	digits = [int(c) for c in i_str]
	return ' '.join([tens[digits[0]], units[digits[1]]])

def minutes_to_word(m):
	quarters = {15: 'quarter', 30: 'half', 45: 'quarter'}
	if m in quarters:
		return quarters[m]
	return int_to_word(m) + ' minutes'

def time_to_words(h, m):
	if m == 0:
		return "{} o' clock".format(int_to_word(h))
	if m <= 30:
		return '{} past {}'.format(minutes_to_word(m), int_to_word(h))
	return '{} to {}'.format(minutes_to_word(60 - m), int_to_word((h + 1) % 12))
H = int(input())
M = int(input())
print(time_to_words(H, M))


hour = int(input())
mins = str(input())
hour_list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one']
mins_list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
mins_dict = {'01': 'one', '02': 'two', '03': 'three', '04': 'four', '05': 'five', '06': 'six', '07': 'seven', '08': 'eight', '09': 'nine', '10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen', '14': 'fourteen', '15': 'fifteen', '16': 'sixteen', '17': 'seventeen', '18': 'eighteen', '19': 'ninteen', '20': 'twenty', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 13: 'thirteen'}
hour_string = hour_list[hour - 1]
for _ in range(1):
	if mins == '00':
		mins_string = "o' clock"
		continue
	if mins == '30':
		mins_string = 'half past ' + hour_string
		del hour_string
		continue
	if mins == '45' or mins == '15':
		mins_string = 'quarter'
		if mins == '45':
			mins_string += ' to '
			mins_string += hour_list[hour]
		elif mins == '15':
			mins_string += ' past '
			mins_string += hour_string
		del hour_string
		continue
	if int(mins) >= 1 and int(mins) < 30:
		if int(mins) == 1:
			mins_string = mins_dict[mins] + ' minute past ' + hour_list[hour - 1]
		elif int(mins) > 1 and int(mins) <= 20:
			mins_string = mins_dict[mins] + ' minutes past ' + hour_list[hour - 1]
		elif int(mins) > 20 and int(mins) < 30:
			mins_string = mins_dict['20'] + ' ' + mins_list[int(mins[1]) - 1] + ' minutes ' + 'past ' + hour_list[hour - 1]
		del hour_string
		continue
	if int(mins) >= 1 and int(mins) <= 59:
		if int(mins) == 59:
			mins_string = mins_dict['01'] + ' minute to ' + hour_list[hour]
		elif int(mins) < 59 and int(mins) >= 40:
			mins_string = mins_dict[int(60 - int(mins))] + ' minutes to ' + hour_list[hour]
		elif int(mins) < 40 and int(mins) > 30:
			mins_string = mins_dict['20'] + ' ' + mins_list[10 - int(mins[1]) - 1] + ' minutes ' + 'to ' + hour_list[hour]
		del hour_string
		continue
try:
	print(hour_string, mins_string)
except NameError:
	print(mins_string)


H = int(input())
M = int(input())
word = 'minutes'
Hour = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
Minute = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'half']
if M == 1:
	word = 'minute'
if M == 0:
	print("{} o' clock".format(Hour[H]))
elif M <= 30:
	if M == 30:
		print('half past {}'.format(Hour[H]))
	elif M == 15:
		print('quarter past {}'.format(Hour[H]))
	else:
		print('{} {} past {}'.format(Minute[M], word, Hour[H]))
elif H == 12:
	if M == 45:
		print('{} to one'.format(Minute[60 - M]))
	else:
		print('{} {} to one'.format(Minute[60 - M], word))
elif M == 45:
	print('{} to {}'.format(Minute[60 - M], Hour[H + 1]))
else:
	print('{} {} to {}'.format(Minute[60 - M], word, Hour[H + 1]))


h = int(input())
m = int(input())
numbers = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']
if m == 0:
	print("{} o' clock".format(numbers[h]))
elif m == 1:
	print('one minute past', numbers[h])
elif m == 59:
	print('one minute to', numbers[h + 1])
elif m == 30:
	print('half past', numbers[h])
elif 60 - m == 15:
	print('quarter to', numbers[(h + 1) % 12])
elif m == 15:
	print('quarter past', numbers[h % 12])
elif m > 30:
	if 60 - m > 20:
		minutes = numbers[20] + ' ' + numbers[(60 - m) % 10]
	else:
		minutes = numbers[60 - m]
	print('{} minutes to {}'.format(minutes, numbers[(h + 1) % 12]))
else:
	if m > 20:
		minutes = numbers[20] + ' ' + numbers[m % 10]
	else:
		minutes = numbers[m]
	print('{} minutes past {}'.format(minutes, numbers[h % 12]))


hour = input()
minutes = input()
ones = {'0': '', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine', '10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'one'}
tens = {'0': '', '1': 'ten', '2': 'twenty', '3': 'thirty', '4': 'forty', '5': 'fifty'}
teens = {'10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen', '14': 'fourteen', '15': 'fifteen', '16': 'sixteen', '17': 'seventeen', '18': 'eighteen', '19': 'nineteen'}
if minutes == '00':
	answer = ones[hour] + " o' clock"
elif minutes == '15':
	answer = 'quarter past ' + ones[hour]
elif minutes == '30':
	answer = 'half past ' + ones[hour]
elif minutes == '45':
	hour = str(int(hour) + 1)
	answer = 'quarter to ' + ones[hour]
elif int(minutes) > 30:
	minutes = str(60 - int(minutes))
	if len(minutes) == 1:
		minutes = '0' + minutes
	hour = str(int(hour) + 1)
	if minutes[0] == '1':
		answer = teens[minutes] + ' minutes to ' + ones[hour]
	elif minutes == '01':
		answer = tens[minutes[0]] + ones[minutes[1]] + ' minute to ' + ones[hour]
	else:
		answer = tens[minutes[0]] + ' ' + ones[minutes[1]] + ' minutes to ' + ones[hour]
elif minutes[0] == '1':
	answer = teens[minutes] + ' minutes past ' + ones[hour]
elif minutes == '01':
	answer = tens[minutes[0]] + ones[minutes[1]] + ' minute past ' + ones[hour]
else:
	answer = tens[minutes[0]] + ' ' + ones[minutes[1]] + ' minutes past ' + ones[hour]
if answer[0] == ' ':
	answer = answer[1:]
print(answer)


numbers = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']
hour = input()
hour = int(hour)
minutes = input()
minutes = int(minutes)
hourString = numbers[hour - 1]
if minutes == 0:
	print(hourString, "o' clock")
elif minutes > 0 and minutes < 30 and (minutes != 15):
	if minutes < 21:
		minuteString = numbers[minutes - 1]
	else:
		unit = minutes - 20
		minuteString = 'twenty ' + numbers[unit - 1]
	print(minuteString, 'minutes past', hourString)
elif minutes == 15:
	print('quarter past', hourString)
elif minutes == 30:
	print('half past', hourString)
elif minutes > 30 and minutes < 60 and (minutes != 45):
	if minutes > 39:
		minutes = 60 - minutes
		minuteString = numbers[minutes - 1]
	else:
		minutes = 60 - minutes
		unit = minutes - 20
		minuteString = 'twenty ' + numbers[unit - 1]
	if hour == 12:
		hourString = 'one'
	else:
		hourString = numbers[hour]
	print(minuteString, 'minutes to', hourString)
elif minutes == 45:
	if hour == 12:
		hourString = 'one'
	else:
		hourString = numbers[hour]
	print('quarter to', hourString)


units = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one']
teens = ['', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
h = int(input())
m = int(input())
if m == 0:
	print(units[h] + " o' clock")
elif m == 1:
	print('one minute past ' + units[h])
elif 2 <= m <= 9:
	print(units[m] + ' minutes past ' + units[h])
elif m == 10:
	print('ten minutes past ' + units[h])
elif m == 15:
	print('quarter past ' + units[h])
elif 11 <= m <= 19:
	print(teens[m % 10] + ' minutes past ' + units[h])
elif m == 20:
	print('twenty minutes past ' + units[h])
elif m == 30:
	print('half past ' + units[h])
elif 21 <= m <= 29:
	print('twenty ' + units[m % 10] + ' minutes past ' + units[h])
elif m == 40:
	print('twenty minutes to ' + units[h + 1])
elif m == 45:
	print('quarter to ' + units[h + 1])
elif 31 <= m <= 39:
	print('twenty ' + units[m % 10] + ' minutes to ' + units[h + 1])
elif 41 <= m <= 49:
	print(teens[10 - m % 10] + ' minutes to ' + units[h + 1])
elif m == 50:
	print('ten minutes to ' + units[h + 1])
elif 51 <= m <= 58:
	print(units[10 - m % 10] + ' minutes to ' + units[h + 1])
else:
	print('one minute to ' + units[h + 1])


def digitToString(x):
	singleDigit = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
	twoDigit = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']
	if x < 10:
		return singleDigit[x]
	elif x <= 20:
		return twoDigit[x - 10]
	else:
		return 'twenty ' + singleDigit[x % 10]
h = int(input())
m = int(input())
if m == 0:
	print(digitToString(h), "o' clock")
elif m == 15:
	print('quarter past', digitToString(h))
elif m < 30:
	print(digitToString(m), 'minutes past', digitToString(h))
elif m == 30:
	print('half past', digitToString(h))
elif m == 45:
	if h == 12:
		h = 0
	print('quarter to', digitToString(h + 1))
else:
	if h == 12:
		h = 0
	print(digitToString(60 - m), 'minutes to', digitToString(h + 1))


ho = int(input())
mi = int(input())
seco = 'N'
ls1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
ls2 = ['one minute', 'two minutes', 'three minutes', 'four minutes', 'five minutes', 'six minutes', 'seven minutes', 'eight minutes', 'nine minutes', 'ten minutes', 'eleven minutes', 'twelve minutes', 'thirteen minutes', 'fourteen minutes', 'quarter', 'sixteen minutes', 'seventeen minutes', 'eighteen minutes', 'nineteen minutes', 'twenty minutes', 'twenty one minutes', 'twenty two minutes', 'twenty three minutes', 'twenty four minutes', 'twenty five minutes', 'twenty six minutes', 'twenty seven minutes', 'twenty eight minutes', 'twenty nine minutes', 'half']
ls3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
ls4 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
if mi > 30:
	seco = 'Y'
	ho += 1
	mi = 60 - mi
if ho > 12:
	ho = 1
for a in range(len(ls3)):
	if ho == ls3[a]:
		hotxt = ls4[a]
if mi == 0:
	res = hotxt + " o' clock"
else:
	for b in range(len(ls1)):
		if mi == ls1[b]:
			if seco == 'Y':
				res = ls2[b] + ' to ' + hotxt
			else:
				res = ls2[b] + ' past ' + hotxt
print(res)


from math import sqrt

def time_in_words(hour, minute):
	dic = {0: "o' clock", 1: 'one minute', 2: 'two minutes', 3: 'three minutes', 4: 'four minutes', 5: 'five minutes', 6: 'six minutes', 7: 'seven minutes', 8: 'eight minutes', 9: 'nine minutes', 10: 'ten minutes', 11: 'eleven minutes', 12: 'twelve minutes', 13: 'thirteen minutes', 14: 'fourteen minutes', 15: 'quarter', 16: 'sixteen minutes', 17: 'seventeen minutes', 18: 'eighteen minutes', 19: 'nineteen minutes', 20: 'twenty minutes', 21: 'twenty one minutes', 22: 'twenty two minutes', 23: 'twenty three minutes', 24: 'twenty four minutes', 25: 'twenty five minutes', 26: 'twenty six minutes', 27: 'twenty seven minutes', 28: 'twenty eight minutes', 29: 'twenty nine minutes', 30: 'half'}
	if minute == 0:
		return dic[hour].split()[0] + ' ' + dic[minute]
	elif minute == 30:
		return dic[minute] + ' past ' + dic[hour].split()[0]
	elif minute < 30:
		return dic[minute] + ' past ' + dic[hour].split()[0]
	else:
		return dic[60 - minute] + ' to ' + dic[(hour + 1) % 12 or 1].split()[0]
h = int(input())
m = int(input())
print(time_in_words(h, m))


h = int(input())
m = int(input())
words = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', '', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
if m == 0:
	print(words[h] + " o' clock")
elif m == 15:
	print('quarter past ' + words[h])
elif m == 30:
	print('half past ' + words[h])
elif m == 45:
	print('quarter to ' + words[h + 1])
elif m < 30:
	print(words[m] + ' minutes past ' + words[h])
elif m > 30:
	print(words[60 - m] + ' minutes to ' + words[h + 1])


import sys
hourdictfuture = {12: 'to one', 11: 'to twelve', 10: 'to eleven', 9: 'to ten', 8: 'to nine', 7: 'to eight', 6: 'to seven', 5: 'to six', 4: 'to five', 3: 'to four', 2: 'to three', 1: 'to two'}
hourdictcurrent = {12: 'twelve', 11: 'eleven', 10: 'ten', 9: 'nine', 8: 'eight', 7: 'seven', 6: 'six', 5: 'five', 4: 'four', 3: 'three', 2: 'two', 1: 'one'}
minutedictfuture = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eigh', 29: 'twenty nine'}
(hour, minute) = map(int, sys.stdin.read().split())
if minute == 0:
	print(hourdictcurrent[hour], "o' clock")
elif minute == 1:
	print(minute, 'minute past', hourdictcurrent[hour])
elif 1 < minute <= 14:
	print(minute, 'minutes past', hourdictcurrent[hour])
elif minute == 15:
	print('quarter past', hourdictcurrent[hour])
elif 15 < minute < 30:
	print(minutedictfuture[minute], 'minutes past', hourdictcurrent[hour])
elif minute == 30:
	print('half past', hourdictcurrent[hour])
elif 31 <= minute < 45:
	print(minutedictfuture[60 - minute], 'minutes', hourdictfuture[hour])
elif minute == 45:
	print('quarter', hourdictfuture[hour])
else:
	print(minutedictfuture[60 - minute], 'minutes', hourdictfuture[hour])


hour = int(input())
minute = int(input())
hours = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one']
singularPre = 'minute to'
pluralPre = 'minutes to'
pre = 'to'
singularPost = 'minute past'
post = 'past'
pluralPost = 'minutes past'
oclock = "o' clock"
halfpast = 'half past'
minutes = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
time = []
if minute == 0:
	time.append(hours[hour - 1])
	time.append(oclock)
elif minute == 30:
	time.append(halfpast)
	time.append(hours[hour - 1])
elif minute < 30:
	time.append(minutes[minute - 1])
	if minute == 1:
		time.append(singularPost)
	elif minute == 15:
		time.append(post)
	else:
		time.append(pluralPost)
	time.append(hours[hour - 1])
else:
	time.append(minutes[60 - minute - 1])
	if minute == 59:
		time.append(singularPre)
	elif minute == 45:
		time.append(pre)
	else:
		time.append(pluralPre)
	time.append(hours[hour])
print(' '.join(time))


import sys
NUMBERS = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
H = int(sys.stdin.readline())
M = int(sys.stdin.readline())
if M == 0:
	print(NUMBERS[H] + " o' clock")
elif M == 15:
	print('quarter past ' + NUMBERS[H])
elif M < 30:
	print(NUMBERS[M] + ' minutes past ' + NUMBERS[H])
elif M == 30:
	print('half past ' + NUMBERS[H])
elif M == 45:
	print('quarter to ' + NUMBERS[(H + 1) % 12])
else:
	print(NUMBERS[60 - M] + ' minutes to ' + NUMBERS[(H + 1) % 12])


words = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'thirty']
hours = int(input())
minutes = int(input())
if minutes == 15:
	print('quarter past', words[hours])
elif minutes == 45:
	print('quarter to', words[hours + 1])
elif minutes > 30:
	minutes = 60 - minutes
	print(words[minutes], 'minutes to', words[hours + 1])
elif minutes == 30:
	print('half past', words[hours])
elif minutes == 0:
	print(words[hours], "o' clock")
else:
	print(words[minutes], 'minutes past', words[hours])


numbers = 'zero one two three four five six seven eight nine'.split()
numbers.extend('ten eleven twelve thirteen fourteen fifteen sixteen'.split())
numbers.extend('seventeen eighteen nineteen'.split())
numbers.extend((tens if ones == 'zero' else tens + ' ' + ones for tens in 'twenty thirty forty fifty sixty seventy eighty ninety'.split() for ones in numbers[0:10]))
h = int(input())
m = int(input())
if m == 0:
	print(numbers[h] + " o' clock")
elif m == 15:
	print('quarter past ' + numbers[h])
elif m == 30:
	print('half past ' + numbers[h])
elif m == 45:
	print('quarter to ' + numbers[h + 1])
elif m < 30:
	print(numbers[m] + ' minutes past ' + numbers[h])
elif m > 30:
	print(numbers[60 - m] + ' minutes to ' + numbers[h + 1])


h = int(input())
m = int(input())
words = 'one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,quarter,sixteen,seventeen,eighteen,nineteen,twenty,twenty one,twenty two,twenty three,twenty four,twenty five,twenty six,twenty seven,twenty eight,twenty nine,half'
words = words.split(',')
time = ''
if m > 0 and m < 31:
	time = time + words[m - 1]
	if m != 15 and m != 30:
		time = time + ' minutes'
	time = time + ' past'
	time = time + ' ' + words[h - 1]
if m > 30 and m < 60:
	time = time + words[60 - m - 1]
	if m != 45:
		time = time + ' minutes'
	time = time + ' to'
	if h != 12:
		time = time + ' ' + words[h]
	else:
		time = time + ' one'
if m == 0:
	time = words[h - 1] + " o' clock"
print(time)


L = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty'}
H = int(input())
M = int(input())
if M == 0:
	print(str(L[H]) + " o' clock")
elif M == 30:
	print('half past ' + str(L[H]))
elif M < 30:
	if M == 15:
		print('quarter past ' + str(L[H]))
	elif M <= 20:
		print(str(L[M]) + ' minutes past ' + str(L[H]) if M > 1 else str(L[M]) + ' minute past ' + str(L[H]))
	else:
		print('twenty ' + str(L[M - 20]) + ' minutes past ' + str(L[H]))
elif 60 - M == 15:
	print('quarter to ' + str(L[1 if H + 1 == 13 else H + 1]))
elif 60 - M <= 20:
	print(str(L[60 - M]) + ' minutes to ' + str(L[1 if H + 1 == 13 else H + 1]) if 60 - M > 1 else str(L[60 - M]) + ' minute to ' + str(L[1 if H + 1 == 13 else H + 1]))
else:
	print('twenty ' + str(L[60 - M - 20]) + ' minutes to ' + str(L[1 if H + 1 == 13 else H + 1]))


def timewords(h, m):
	words = ['twelve', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
	hour = words[h]
	if m > 30:
		hour = words[h + 1]
		minutes = words[60 - m]
		if m == 45:
			return 'quarter to %s' % hour
		else:
			return '%s minutes to %s' % (minutes, hour)
	elif m == 0:
		return "%s o' clock" % hour
	elif m < 30:
		minutes = words[m]
		if m == 1:
			return '%s minute past %s' % (minutes, hour)
		if m == 15:
			return 'quarter past %s' % hour
		else:
			return '%s minutes past %s' % (minutes, hour)
	elif m == 30:
		return 'half past %s' % hour
	else:
		return 'You done messed up'
hour = int(input())
minutes = int(input())
print(timewords(hour, minutes))


hours = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one']
minutes = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
h = int(input())
m = int(input())
m1 = m // 10
m2 = m % 10
output = ''
if m == 0:
	output = hours[h] + " o' clock"
elif m == 15:
	output = 'quarter past ' + hours[h]
elif m == 30:
	output = 'half past ' + hours[h]
elif m == 45:
	output = 'quarter to ' + hours[h + 1]
else:
	prep = ' past '
	hour = hours[h]
	if m > 30:
		m = 60 - m
		prep = ' to '
		hour = hours[h + 1]
	m1 = m // 10
	m2 = m % 10
	if m == 1:
		output = 'one minute' + prep + hour
	elif m < 20:
		output = minutes[m] + ' minutes' + prep + hour
	else:
		output = 'twenty ' + minutes[m2] + ' minutes' + prep + hour
print(output)


dict = {}
dict[0] = 'zero'
dict[1] = 'one'
dict[2] = 'two'
dict[3] = 'three'
dict[4] = 'four'
dict[5] = 'five'
dict[6] = 'six'
dict[7] = 'seven'
dict[8] = 'eight'
dict[9] = 'nine'
dict[10] = 'ten'
dict[11] = 'eleven'
dict[12] = 'twelve'
dict[13] = 'thirteen'
dict[14] = 'fourteen'
dict[15] = 'fifteen'
dict[16] = 'sixteen'
dict[17] = 'seventeen'
dict[18] = 'eighteen'
dict[19] = 'nineteen'
dict[20] = 'twenty'
dict[30] = 'thirty'
dict[40] = 'forty'
dict[50] = 'fifty'

def getTime(num):
	if num == 15:
		return 'quarter'
	if num == 30:
		return 'half'
	if num <= 20:
		return dict[num]
	(shi, fen) = (num - num % 10, num % 10)
	if fen == 0:
		return dict[shi]
	else:
		return dict[shi] + ' ' + dict[fen]

def main():
	n = int(input())
	m = int(input())
	ans = ''
	if m > 30:
		pt = 'to'
		n = n % 12 + 1
		m = 60 - m
	else:
		pt = 'past'
	if m == 1:
		minute = 'minute'
	else:
		minute = 'minutes'
	if m == 0:
		ans = getTime(n) + " o' clock"
	elif m == 15 or m == 30:
		ans = getTime(m) + ' ' + pt + ' ' + getTime(n)
	else:
		ans = getTime(m) + ' ' + minute + ' ' + pt + ' ' + getTime(n)
	print(ans)
main()


H = int(input())
M = int(input())
Direction = ''
if M == 0:
	Direction = ''
elif M <= 30:
	Direction = 'past'
else:
	Direction = 'to'
if M > 30:
	M = 60 - M
	H = H + 1
	H = H % 12
Hour = ''
if H == 1:
	Hour = 'one'
elif H == 2:
	Hour = 'two'
elif H == 3:
	Hour = 'three'
elif H == 4:
	Hour = 'four'
elif H == 5:
	Hour = 'five'
elif H == 6:
	Hour = 'six'
elif H == 7:
	Hour = 'seven'
elif H == 8:
	Hour = 'eight'
elif H == 9:
	Hour = 'nine'
elif H == 10:
	Hour = 'ten'
elif H == 11:
	Hour = 'eleven'
elif H == 12:
	Hour = 'twelve'
Minutes = ''
if M == 15:
	Minutes = 'quarter'
elif M == 30:
	Minutes = 'half'
else:
	M_mod_10 = M % 10
	M_div_10 = M // 10
	if M_div_10 == 1:
		if M_mod_10 == 0:
			Minutes = 'ten'
		elif M_mod_10 == 1:
			Minutes = 'eleven'
		elif M_mod_10 == 2:
			Minutes = 'twelve'
		elif M_mod_10 == 3:
			Minutes = 'thirteen'
		elif M_mod_10 == 4:
			Minutes = 'fourteen'
		elif M_mod_10 == 5:
			Minutes = 'fifteen'
		elif M_mod_10 == 6:
			Minutes = 'sixteen'
		elif M_mod_10 == 7:
			Minutes = 'seventeen'
		elif M_mod_10 == 8:
			Minutes = 'eighteen'
		elif M_mod_10 == 9:
			Minutes = 'nineteen'
	else:
		if M_div_10 == 2:
			Minutes += 'twenty '
		if M_mod_10 == 1:
			Minutes += 'one'
		elif M_mod_10 == 2:
			Minutes += 'two'
		elif M_mod_10 == 3:
			Minutes += 'three'
		elif M_mod_10 == 4:
			Minutes += 'four'
		elif M_mod_10 == 5:
			Minutes += 'five'
		elif M_mod_10 == 6:
			Minutes += 'six'
		elif M_mod_10 == 7:
			Minutes += 'seven'
		elif M_mod_10 == 8:
			Minutes += 'eight'
		elif M_mod_10 == 9:
			Minutes += 'nine'
	Minutes += ' minutes'
if Direction == '':
	print(Hour + " o' clock")
else:
	print(Minutes + ' ' + Direction + ' ' + Hour)


import sys
NUMBERS = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
H = int(sys.stdin.readline())
M = int(sys.stdin.readline())
if M == 0:
	print(NUMBERS[H] + " o' clock")
elif M == 15:
	print('quarter past ' + NUMBERS[H])
elif M < 30:
	print(NUMBERS[M] + ' minutes past ' + NUMBERS[H])
elif M == 30:
	print('half past ' + NUMBERS[H])
elif M == 45:
	print('quarter to ' + NUMBERS[(H + 1) % 12])
else:
	print(NUMBERS[60 - M] + ' minutes to ' + NUMBERS[(H + 1) % 12])


hour = int(input())
minute = int(input())
readings = {'1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine', '10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen', '14': 'fourteen', '15': 'quarter', '16': 'sixteen', '17': 'seventeen', '18': 'eighteen', '19': 'ninteen', '20': 'twenty', '21': 'twenty one', '22': 'twenty two', '23': 'twenty three', '24': 'twenty four', '25': 'twenty five', '26': 'twenty six', '27': 'twenty seven', '28': 'twenty eight', '29': 'twenty nine', '30': 'thirty'}
if minute == 0:
	print("%s o' clock" % readings[str(hour)])
elif minute == 15:
	print('%s past %s' % (readings[str(minute)], readings[str(hour)]))
elif minute < 30:
	print('%s minutes past %s' % (readings[str(minute)], readings[str(hour)]))
elif minute == 30:
	print('half past %s' % readings[str(hour)])
elif minute == 45:
	print('%s to %s' % (readings[str(60 - minute)], readings[str(hour + 1)]))
else:
	print('%s minutes to %s' % (readings[str(60 - minute)], readings[str(hour + 1)]))


hora = int(input())
mins = int(input())
horas = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'one'}
s_minutes = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
m_units = {'1': 'one ', '2': 'two ', '3': 'three ', '4': 'four ', '5': 'five ', '6': 'six ', '7': 'seven ', '8': 'eight ', '9': 'nine ', '0': ''}
m_tens = {'2': 'twenty', '3': 'thirty', '4': 'fourty', '5': 'fifty'}

def inwords(h, m):
	if m == 1:
		return 'one minute past ' + horas[h]
	if m == 0:
		return horas[h] + " o' clock"
	if m == 30:
		return 'half past ' + horas[h]
	if m == 15:
		return 'quarter past ' + horas[h]
	if m < 20:
		return s_minutes[m] + ' minutes past ' + horas[h]
	if m == 45:
		return 'quarter to ' + horas[h + 1]
	if m >= 20 and m < 30:
		a = str(m)[0]
		b = str(m)[1]
		return m_tens[a] + ' ' + m_units[b] + 'minutes past ' + horas[h]
	if m > 30 and m <= 40:
		m = 60 - m
		a = str(m)[0]
		b = str(m)[1]
		return m_tens[a] + ' ' + m_units[b] + 'minutes to ' + horas[h + 1]
	if m > 45:
		m = 60 - m
		return s_minutes[m] + ' minutes to ' + horas[h + 1]
print(inwords(hora, mins))


dados_texto = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eigth', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eigth', 'twenty nine', 'thirty', 'thirty one', 'thirty two', 'thirty three', 'thirty four', 'thirty five', 'thirty six', 'thirty seven', 'thirty eigth', 'thirty nine', 'forty', 'forty one', 'forty two', 'forty three', 'forty four', 'forty five', 'forty six', 'forty seven', 'forty eigth', 'forty nine', 'fifty', 'fifty one', 'fifty two', 'fifty three', 'fifty four', 'fifty five', 'fifty six', 'fifty seven', 'fifty eigth', 'fifty nine']

def EscreveHoraPorExtenso(hora, minuto):
	if minuto == 0:
		return dados_texto[hora - 1] + " o' clock"
	elif minuto == 30:
		return 'half past ' + dados_texto[hora - 1]
	elif minuto == 15:
		return 'quarter past ' + dados_texto[hora - 1]
	elif minuto == 45:
		if hora == 12:
			return 'quarter to ' + dados_texto[0]
		else:
			return 'quarter to ' + dados_texto[hora]
	elif minuto < 30:
		if minuto == 1:
			return dados_texto[minuto - 1] + ' minute past ' + dados_texto[hora - 1]
		else:
			return dados_texto[minuto - 1] + ' minutes past ' + dados_texto[hora - 1]
	elif minuto > 30:
		if hora == 12:
			return dados_texto[60 - minuto - 1] + ' minutes to ' + dados_texto[0]
		else:
			return dados_texto[60 - minuto - 1] + ' minutes to ' + dados_texto[hora]
	else:
		return 'ERROR'
hora = int(input())
minuto = int(input())
print(EscreveHoraPorExtenso(hora, minuto))


numbers = 'zero one two three four five six seven eight nine'.split()
numbers.extend('ten eleven twelve thirteen fourteen fifteen sixteen'.split())
numbers.extend('seventeen eighteen nineteen'.split())
numbers.extend((tens if ones == 'zero' else tens + ' ' + ones for tens in 'twenty thirty forty fifty sixty seventy eighty ninety'.split() for ones in numbers[0:10]))
hour = int(input().strip())
minute = int(input().strip())
numbers[15] = 'quarter'
numbers[30] = 'half'
if minute == 0:
	print(numbers[hour] + " o' clock")
elif minute == 15 or minute == 30:
	print(numbers[minute] + ' past ' + numbers[hour])
elif minute == 45:
	print(numbers[60 - minute] + ' to ' + numbers[hour + 1])
elif minute < 30:
	print(numbers[minute] + ' minutes past ' + numbers[hour])
elif hour == 12:
	print(numbers[60 - minute] + ' minutes to ' + numbers[1])
else:
	print(numbers[60 - minute] + ' minutes to ' + numbers[hour + 1])


h = int(input())
m = int(input())
s = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
if m > 30:
	if m == 45:
		print('quarter to ' + s[h + 1])
	elif m == 59:
		print('one minute to ' + s[h + 1])
	else:
		print(s[60 - m] + ' minutes to ' + s[h + 1])
elif m < 30:
	if m == 0:
		print(s[h] + " o' clock")
	elif m == 15:
		print('quarter past ' + s[h])
	elif m == 1:
		print('one minute past ' + s[h])
	else:
		print(s[m] + ' minutes past ' + s[h])
elif m == 30:
	print('half past ' + s[h])


H = int(input())
M = int(input())

def to_word(n):
	smalls = ('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen')
	tens = ('twenty', 'thirty', 'fourty', 'fifty')
	if n < 20 and n != 15:
		return smalls[n]
	if n in (15, 30, 45):
		return ('quarter', 'half', 'quarter')[n // 15 - 1]
	a = list(str(n))
	if a[1] == '0':
		return tens[int(a[0]) - 2]
	return tens[int(a[0]) - 2] + ' ' + smalls[int(a[1])]
if M == 0:
	print(to_word(H), "o' clock")
else:
	hour = []
	minute = []
	if M > 30:
		hour += list('to ' + to_word(H + 1))
		M = 60 - M
	else:
		hour += list('past ' + to_word(H))
	minute += list(to_word(M) + ' ')
	if M not in (15, 30, 45):
		if M == 1:
			minute += list('minute ')
		else:
			minute += list('minutes ')
	print(''.join(minute + hour))


hours = int(input())
minutes = int(input())
hours_varians = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'tvelve'}
minutes_varius = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'tvelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 150: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 300: 'half'}
result = ''
if minutes != 0:
	if minutes <= 30:
		result += ' past ' + hours_varians[hours]
	else:
		result += ' to ' + hours_varians[hours + 1]
		minutes = 60 - minutes
	if minutes == 30 or minutes == 15:
		result = minutes_varius[minutes * 10] + result
	elif minutes < 20:
		result = minutes_varius[minutes] + ' minutes' + result
	else:
		result = minutes_varius[20] + ' ' + minutes_varius[int(str(minutes)[1])] + ' minutes' + result
else:
	result = hours_varians[hours] + " o' clock"
print(result)


num2words1 = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Quarter', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen', 'Twenty', 'Twenty One', 'Twenty Two', 'Twenty Three', 'Twenty Four', 'Twenty Five', 'Twenty Six', 'Twenty Seven', 'Twenty Eight', 'Twenty Nine', 'Half']
hour = int(input())
minutes = int(input())
if minutes == 0:
	print(num2words1[hour].lower(), "o' clock")
	exit()
if minutes == 30:
	print('half past', num2words1[hour].lower())
if minutes < 30 and minutes != 15:
	if minutes == 1:
		print(num2words1[minutes].lower(), 'minute past', num2words1[hour].lower())
	else:
		print(num2words1[minutes].lower(), 'minutes past', num2words1[hour].lower())
elif minutes > 30 and minutes != 45:
	minutes = 60 - minutes
	if minutes == 1:
		print(num2words1[minutes].lower(), 'minute to', num2words1[hour + 1].lower())
	else:
		print(num2words1[minutes].lower(), 'minutes to', num2words1[hour + 1].lower())
elif minutes == 15:
	print(num2words1[minutes].lower(), 'past', num2words1[hour].lower())
elif minutes == 45:
	minutes = 60 - minutes
	print(num2words1[minutes].lower(), 'to', num2words1[hour + 1].lower())


__author__ = 'danielbaeck'
numbrs = ['twelve', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'thirty']
exact = {15: 'quarter', 30: 'half', 45: 'quarter'}
h = int(input()) % 12
m = int(input())
if m == 0:
	print(numbrs[h] + " o' clock")
elif m <= 30:
	if m in exact:
		print(exact[m] + ' past ' + numbrs[h])
	else:
		print(numbrs[m] + ' minutes past ' + numbrs[h])
elif m in exact:
	print(exact[m] + ' to ' + numbrs[(h + 1) % 12])
else:
	print(numbrs[60 - m] + ' minutes to ' + numbrs[(h + 1) % 12])


numbers = {}
numbers[1] = 'one'
numbers[2] = 'two'
numbers[3] = 'three'
numbers[4] = 'four'
numbers[5] = 'five'
numbers[6] = 'six'
numbers[7] = 'seven'
numbers[8] = 'eight'
numbers[9] = 'nine'
numbers[10] = 'ten'
numbers[11] = 'eleven'
numbers[12] = 'twelve'
numbers[13] = 'thirteen'
numbers[14] = 'fourteen'
numbers[15] = 'quarter'
numbers[16] = 'sixteen'
numbers[17] = 'seventeen'
numbers[18] = 'eighteen'
numbers[19] = 'nineteen'
numbers[20] = 'twenty'
numbers[21] = 'twenty one'
numbers[22] = 'twenty two'
numbers[23] = 'twenty three'
numbers[24] = 'twenty four'
numbers[25] = 'twenty five'
numbers[26] = 'twenty six'
numbers[27] = 'twenty seven'
numbers[28] = 'twenty eight'
numbers[29] = 'twenty nine'
h = int(input())
m = int(input())
if m == 1:
	print('one minute past', numbers[h])
elif m == 59:
	print('one minute to', numbers[h + 1]) if h < 12 else print('one minute to one')
elif m == 15:
	print('quarter past', numbers[h])
elif m == 45:
	print('quarter to', numbers[h + 1]) if h < 12 else print('quarter to one')
elif m == 0:
	print(numbers[h], "o' clock")
elif m == 30:
	print('half past', numbers[h])
elif m < 30:
	print(numbers[m], 'minutes past', numbers[h])
elif m > 30:
	print(numbers[60 - m], 'minutes to', numbers[h + 1]) if h < 12 else print(numbers[60 - m], 'minutes to one')


hour = int(input())
minutes = int(input())
HOUR_NUMERALS = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve'}
MINUTE_NUMERALS = {1: 'one minute', 2: 'two minutes', 3: 'three minutes', 4: 'four minutes', 5: 'five minutes', 6: 'six minutes', 7: 'seven minutes', 8: 'eight minutes', 9: 'nine minutes', 10: 'ten minutes', 11: 'eleven minutes', 12: 'twelve minutes', 13: 'thirteen minutes', 14: 'fourteen minutes', 15: 'quarter', 16: 'sixteen minutes', 17: 'seventeen minutes', 18: 'eighteen minutes', 19: 'nineteen minutes', 20: 'twenty minutes', 21: 'twenty one minutes', 22: 'twenty two minutes', 23: 'twenty three minutes', 24: 'twenty four minutes', 25: 'twenty five minutes', 26: 'twenty six minutes', 27: 'twenty seven minutes', 28: 'twenty eight minutes', 29: 'twenty nine minutes', 30: 'half'}
if not minutes:
	print("%s o' clock" % (HOUR_NUMERALS[hour],))
elif minutes > 30:
	print('%s to %s' % (MINUTE_NUMERALS[60 - minutes], HOUR_NUMERALS[hour % 12 + 1]))
else:
	print('%s past %s' % (MINUTE_NUMERALS[minutes], HOUR_NUMERALS[hour]))


hours_dict = {'0': 'midnight', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine', '10': 'ten', '11': 'eleven', '12': 'twelve'}
minutes_dict = {'0': "o' clock", '1': 'one minute', '2': 'two minutes', '3': 'three minutes', '4': 'four minutes', '5': 'five minutes', '6': 'six minutes', '7': 'seven minutes', '8': 'eight minutes', '9': 'nine minutes', '10': 'ten minutes', '11': 'eleven minutes', '12': 'twelve minutes', '13': 'thirteen minutes', '14': 'fourteen minutes', '15': 'quarter', '16': 'sixteen minutes', '17': 'seventeen minutes', '18': 'eighteen minutes', '19 minutes': 'nineteen minutes', '20': 'twenty minutes', '21': 'twenty one minutes', '22': 'twenty two minutes', '23': 'twenty three minutes', '24': 'twenty four minutes', '25': 'twenty five minutes', '26': 'twenty six minutes', '27': 'twenty seven minutes', '28': 'twenty eight minutes', '29': 'twenty nine minutes', '30': 'half'}

def to_text(hours, minutes):
	if minutes == 0:
		return hours_dict[str(hours)] + ' ' + minutes_dict[str(minutes)]
	elif minutes <= 30:
		return minutes_dict[str(minutes)] + ' past ' + hours_dict[str(hours)]
	else:
		return minutes_dict[str(60 - minutes)] + ' to ' + hours_dict[str(hours + 1)]
print(to_text(int(input()), int(input())))


def time_in_words(H, M):
	words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'half']
	if H > 12:
		H %= 12
	if M == 0:
		return "%s o' clock" % words[H - 1]
	elif M <= 30:
		if M == 1:
			return '%s minute past %s' % (words[M - 1], words[H - 1])
		elif M == 15 or M == 30:
			return '%s past %s' % (words[M - 1], words[H - 1])
		else:
			return '%s minutes past %s' % (words[M - 1], words[H - 1])
	else:
		M = 60 - M
		if M == 1:
			return '%s minute to %s' % (words[M - 1], words[H])
		elif M == 15:
			return '%s to %s' % (words[M - 1], words[H])
		else:
			return '%s minutes to %s' % (words[M - 1], words[H])

def main():
	(H, M) = (int(input()), int(input()))
	print(time_in_words(H, M))
main()


taskM = {'0': "%s o' clock", '1': '%s minutes past %s', '15': 'quarter past %s', '30': 'half past %s', '45': 'quarter to %s', '2': '%s minutes to %s'}
taskH = {'1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine', '10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen', '14': 'fourteen', '15': 'fifteen', '16': 'sixteen', '17': 'seventeen', '18': 'eighteen', '19': 'nineteen', '20': 'twenty', '21': 'twenty one', '22': 'twenty two', '23': 'twenty three', '24': 'twenty four', '25': 'twenty five', '26': 'twenty six', '27': 'twenty seven', '28': 'twenty eight', '29': 'twenty nine'}
H = int(input())
M = int(input())
if M > 30:
	if H == 12:
		H = 1
	else:
		H += 1
if M == 15 or M == 30 or M == 45:
	print(taskM[str(M)] % taskH[str(H)])
elif M == 0:
	print(taskM['0'] % taskH[str(H)])
elif M <= 30:
	print(taskM['1'] % (taskH[str(M)], taskH[str(H)]))
else:
	print(taskM['2'] % (taskH[str(60 - M)], taskH[str(H)]))


hours = ['twelve', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
minutes = ["{1} o' clock", 'one minute {0} {1}', 'two minutes {0} {1}', 'three minutes {0} {1}', 'four minutes {0} {1}', 'five minites {0} {1}', 'six minutes {0} {1}', 'seven minutes {0} {1}', 'eight minutes {0} {1}', 'nine minutes {0} {1}', 'ten minutes {0} {1}', 'eleven minutes {0} {1}', 'twelve minutes {0} {1}', 'thirteen minutes {0} {1}', 'fourteen minutes {0} {1}', 'quarter {0} {1}', 'sixteen minutes {0} {1}', 'seventeen minutes {0} {1}', 'eighteen minutes {0} {1}', 'nineteen minutes {0} {1}', 'twenty minutes {0} {1}', 'twenty one minute {0} {1}', 'twenty two minutes {0} {1}', 'twenty three minutes {0} {1}', 'twenty four minutes {0} {1}', 'twenty five minutes {0} {1}', 'twenty six minutes {0} {1}', 'twenty seven minutes {0} {1}', 'twenty eight minutes {0} {1}', 'twenty nine minutes {0} {1}', 'half {0} {1}']
H = int(input())
M = int(input())
if M <= 30:
	past = True
else:
	past = False
	M = 60 - M
print(minutes[M].format('past' if past else 'to', hours[H if past else H + 1]))


names = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']
h = int(input())
m = int(input())
if m == 0:
	print(names[h], "o' clock")
elif m == 1:
	print('one minute past', names[h])
elif m == 15:
	print('quarter past', names[h])
elif m == 30:
	print('half past', names[h])
elif m <= 20:
	print(names[m], 'minutes past', names[h])
elif m < 30:
	m -= 20
	print('twenty', names[m], 'minutes past', names[h])
else:
	if h == 12:
		h = 1
	else:
		h += 1
	m = 60 - m
	if m == 15:
		print('quarter to', names[h])
	elif m == 1:
		print('one minute to', names[h])
	elif m <= 20:
		print(names[m], 'minutes to', names[h])
	else:
		m -= 20
		print('twenty', names[m], 'minutes to', names[h])


H = int(input())
M = int(input())
values = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
for prefix in ['twenty', 'thirty', 'forty', 'fifty']:
	values.append(prefix)
	for i in range(1, 10):
		values.append(prefix + ' ' + values[i])
if M == 0:
	print(values[H] + " o' clock")
elif M == 15:
	print('quarter past ' + values[H])
elif M == 30:
	print('half past ' + values[H])
elif M == 45:
	print('quarter to ' + values[H + 1 if H < 12 else 1])
elif M == 1:
	print(values[M] + ' minute past ' + values[H])
elif M == 59:
	print(values[60 - M] + ' minute to ' + values[H + 1 if H < 12 else 1])
elif M < 30:
	print(values[M] + ' minutes past ' + values[H])
else:
	print(values[60 - M] + ' minutes to ' + values[H + 1 if H < 12 else 1])


import sys
NUMBERS = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
H = int(sys.stdin.readline())
M = int(sys.stdin.readline())
if M == 0:
	print(NUMBERS[H] + " o' clock")
elif M == 15:
	print('quarter past ' + NUMBERS[H])
elif M < 30:
	print(NUMBERS[M] + ' minutes past ' + NUMBERS[H])
elif M == 30:
	print('half past ' + NUMBERS[H])
elif M == 45:
	print('quarter to ' + NUMBERS[(H + 1) % 12])
else:
	print(NUMBERS[60 - M] + ' minutes to ' + NUMBERS[(H + 1) % 12])


ntw = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine', 0: 'zero'}

def spl(n, H):
	if n == 0:
		print(ntw[H], "o' clock")
	elif n == 1:
		print('quarter past', ntw[H])
	elif n == 2:
		print('half past', ntw[H])
	elif n == 3:
		print('quarter to', ntw[H + 1])
	return None

def nor(M, H):
	if M == 1:
		print(ntw[M], 'minute past', ntw[H])
	elif M < 30:
		print(ntw[M], 'minutes past', ntw[H])
	else:
		M = 60 - M
		if M == 1:
			print(ntw[M], 'minute to', ntw[H + 1])
		elif M < 30:
			print(ntw[M], 'minutes to', ntw[H + 1])
	return None
H = int(input().strip())
M = int(input().strip())
if not M % 15:
	spl(int(M / 15), H)
else:
	nor(M, H)


(h, m) = (int(input()), int(input()))
num_dict = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine', 31: 'thirty one', 32: 'thirty two', 33: 'thirty three', 34: 'thirty four', 35: 'thirty five', 36: 'thirty six', 37: 'thirty seven', 38: 'thirty eight', 39: 'thirty nine'}
(hword, mword) = ('', '')
if m == 0:
	mword = str(num_dict[h])
	hword = " o' clock"
elif m <= 30:
	hword = ' ' + str(num_dict[h])
	if m == 30:
		mword = 'half past'
	elif m == 15:
		mword = 'quarter past'
	elif m == 1:
		mword = 'one minute past'
	elif m > 1:
		mword = str(num_dict[m]) + ' minutes past'
elif m > 30:
	if h < 12:
		hword = ' ' + str(num_dict[h + 1])
	elif h == 12:
		hword = ' one'
	if m == 45:
		mword = 'quarter to'
	elif m < 59:
		mword = str(num_dict[60 - m]) + ' minutes to'
	elif m == 59:
		mword = 'one minute to'
print(mword, hword, sep='')


import os
import sys

def getTime(hrs, mins):
	numList = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'ninteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
	if mins > 30:
		hour = numList[hrs + 1]
	else:
		hour = numList[hrs]
	if mins == 0:
		time = hour + " o' clock"
	elif mins == 15:
		time = 'quarter past ' + hour
	elif mins < 30:
		time = numList[mins] + ' minutes past ' + hour
	elif mins == 30:
		time = 'half past ' + hour
	elif mins != 45:
		time = numList[60 - mins] + ' minutes to ' + hour
	else:
		time = 'quarter to ' + hour
	print(time)

def main():
	hours = int(input())
	minutes = int(input())
	getTime(hours, minutes)
main()


def hourinwords(a):
	listofhours = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']
	return listofhours[a - 1]

def mininwords(b):
	listoftensdigit = ['twenty', 'thirty', 'forty', 'fifty', 'sixty']
	listofonesdigit = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
	str = ''
	if len(b) == 1:
		b = '0' + b
	if b == '01':
		str = 'one minute'
	elif b == '10':
		str = 'ten minutes'
	elif b[0] == '0':
		str = listofonesdigit[int(b[1]) - 1] + ' minutes'
	elif b[0] == '1':
		str = listofonesdigit[int(b) - 1] + ' minutes'
	elif b[1] == '0':
		str = listoftensdigit[int(b[0]) - 2] + ' minutes'
	else:
		str = listoftensdigit[int(b[0]) - 2] + ' ' + listofonesdigit[int(b[1]) - 1] + ' minutes'
	return str
hour = int(input())
minutes = input()
if minutes == '00':
	print(hourinwords(hour) + " o' clock")
elif minutes == '15':
	print('quarter past ' + hourinwords(hour))
elif minutes == '30':
	print('half past ' + hourinwords(hour))
elif int(minutes) < 30:
	print(mininwords(minutes) + ' past ' + hourinwords(hour))
elif minutes == '45':
	print('quarter to ' + hourinwords(hour + 1))
else:
	print(mininwords(str(60 - int(minutes))) + ' to ' + hourinwords(hour + 1))


numbers = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']
H = int(input())
M = int(input())
dir = ' past '
if M == 0:
	print(numbers[H] + " o' clock")
else:
	if M > 30:
		M = 60 - M
		dir = ' to '
		H += 1
	if M == 30:
		print('half past ' + numbers[H])
	elif M == 15:
		print(numbers[M] + dir + numbers[H])
	elif M == 1:
		print(numbers[M] + ' minute' + dir + numbers[H])
	elif M > 20:
		minutes = M - 20
		print(numbers[20] + ' ' + numbers[minutes] + ' minutes' + dir + numbers[H])
	else:
		print(numbers[M] + ' minutes' + dir + numbers[H])


_dict = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
h = int(input())
m = int(input())
if m == 0:
	print("%s o' clock" % _dict[h])
elif m == 30:
	print('half past %s' % _dict[h])
elif m == 15:
	print('quarter past %s' % _dict[h])
elif m == 45:
	print('quarter to %s' % _dict[(h + 1) % 12])
elif m < 30:
	print('%s minute%s past %s' % (_dict[m], ['', 's'][m > 1], _dict[h]))
else:
	print('%s minute%s to %s' % (_dict[30 - (m - 30)], ['', 's'][m != 59], _dict[(h + 1) % 12]))


words = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
hour = int(input())
minute = int(input())
if minute == 0:
	print(words[hour] + " o' clock")
elif minute == 15:
	print('quarter past ' + words[hour])
elif minute == 30:
	print('half past ' + words[hour])
elif minute == 45:
	if hour == 12:
		print('quarter to one')
	else:
		print('quarter to ' + words[hour + 1])
elif minute < 30:
	print(words[minute] + ' minutes past ' + words[hour])
elif hour == 12:
	print(words[30 - minute] + ' minutes to one')
else:
	print(words[30 - minute] + ' minutes to ' + words[hour + 1])


num = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
h = int(input())
m = int(input())
if m == 0:
	print(num[h] + " o' clock")
elif m == 15:
	print('quarter past ' + num[h])
elif m < 30:
	print(num[m] + ' minutes past ' + num[h])
elif m == 30:
	print('half past ' + num[h])
elif m == 45:
	print('quarter to ' + num[(h + 1) % 12])
else:
	print(num[60 - m] + ' minutes to ' + num[(h + 1) % 12])


import sys
NUMBERS = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
H = int(sys.stdin.readline())
M = int(sys.stdin.readline())
if M == 0:
	print(NUMBERS[H] + " o' clock")
elif M == 15:
	print('quarter past ' + NUMBERS[H])
elif M < 30:
	print(NUMBERS[M] + ' minutes past ' + NUMBERS[H])
elif M == 30:
	print('half past ' + NUMBERS[H])
elif M == 45:
	print('quarter to ' + NUMBERS[(H + 1) % 12])
else:
	print(NUMBERS[60 - M] + ' minutes to ' + NUMBERS[(H + 1) % 12])


import sys
NUMBERS = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
H = int(sys.stdin.readline())
M = int(sys.stdin.readline())
if M == 0:
	print(NUMBERS[H] + " o' clock")
elif M == 15:
	print('quarter past ' + NUMBERS[H])
elif M < 30:
	print(NUMBERS[M] + ' minutes past ' + NUMBERS[H])
elif M == 30:
	print('half past ' + NUMBERS[H])
elif M == 45:
	print('quarter to ' + NUMBERS[(H + 1) % 12])
else:
	print(NUMBERS[60 - M] + ' minutes to ' + NUMBERS[(H + 1) % 12])


import sys
dtow = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
H = int(input())
M = int(input())
if M == 0:
	print(dtow[H] + " o' clock")
elif M == 15:
	print('quarter past ' + dtow[H])
elif M < 30:
	print(dtow[M] + ' minutes past ' + dtow[H])
elif M == 30:
	print('half past ' + dtow[H])
elif M == 45:
	print('quarter to ' + dtow[(H + 1) % 12])
else:
	print(dtow[60 - M] + ' minutes to ' + dtow[(H + 1) % 12])


numerals = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'half']
hours = int(input())
minutes = int(input())
pastOrTo = 'past'
if minutes > 30:
	hours += 1
	minutes = 60 - minutes
	pastOrTo = 'to'
hours = numerals[hours]
if minutes == 0:
	print(hours + " o' clock")
elif minutes == 1:
	print(numerals[minutes] + ' minute past ' + hours)
elif minutes == 15 or minutes == 30:
	print(numerals[minutes] + ' ' + pastOrTo + ' ' + hours)
else:
	print(numerals[minutes] + ' minutes ' + pastOrTo + ' ' + hours)


(H, M) = map(int, (input(), input()))

def wordify(h, m):
	N2L = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty one', 22: 'twenty two', 23: 'twenty three', 24: 'twenty four', 25: 'twenty five', 26: 'twenty six', 27: 'twenty seven', 28: 'twenty eight', 29: 'twenty nine'}
	if m == 0:
		return N2L[h] + " o' clock"
	elif m == 15:
		return 'quarter past ' + N2L[h]
	elif m == 30:
		return 'half past ' + N2L[h]
	elif m < 30:
		units = 'minute' if m == 1 else 'minutes'
		return '{} {} past {}'.format(N2L[m], units, N2L[h])
	elif m == 45:
		nexthour = (h + 1) % 12
		return 'quarter to ' + N2L[nexthour]
	else:
		timeleft = 60 - m
		nexthour = (h + 1) % 12
		units = 'minute' if timeleft == 1 else 'minutes'
		return '{} {} to {}'.format(N2L[timeleft], units, N2L[nexthour])
print(wordify(H, M))


numbers_as_words_list = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'thirty']
hour = int(input())
minute = int(input())
hour_word = numbers_as_words_list[hour]
next_hour_word = numbers_as_words_list[hour + 1] if hour < 12 else numbers_as_words_list[1]
minute_word = numbers_as_words_list[minute if minute <= 30 else 60 - minute]
if minute == 0:
	string = "{} o' clock".format(hour_word)
if minute == 30:
	string = 'half past {}'.format(hour_word)
if minute == 15:
	string = 'quarter past {}'.format(hour_word)
if minute == 45:
	string = 'quarter to {}'.format(next_hour_word)
if minute > 0 and minute < 30 and (minute != 15):
	string = '{} minutes past {}'.format(minute_word, hour_word)
if minute > 30 and minute < 60 and (minute != 45):
	string = '{} minutes to {}'.format(minute_word, next_hour_word)
print(string)


H = int(input())
M = int(input())
lists = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'thirty']
if M == 0:
	ans2 = lists[H - 1]
	print("{} o' clock".format(ans2))
if M == 30:
	ans2 = lists[H - 1]
	print('half past {}'.format(ans2))
if M < 30 and M > 0:
	if M == 15:
		ans2 = lists[H - 1]
		print('quarter past {}'.format(ans2))
	else:
		ans1 = lists[M - 1]
		ans2 = lists[H - 1]
		print('{} minutes past {}'.format(ans1, ans2))
if M > 30:
	if M == 45:
		ans2 = lists[H]
		print('quarter to {}'.format(ans2))
	else:
		temp = 60 - M
		ans1 = lists[temp - 1]
		ans2 = lists[H]
		print('{} minutes to {}'.format(ans1, ans2))


time_dict = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty'}

def hour_to_str(hour_digit):
	return time_dict[hour_digit]

def min_to_str(min_digit):
	if min_digit < 21:
		return time_dict[min_digit]
	else:
		return 'twenty {}'.format(time_dict[min_digit % 10])
hour = int(input())
mins = int(input())
if mins == 0:
	print("{} o' clock".format(hour_to_str(hour)))
elif mins == 30:
	print('half past {}'.format(hour_to_str(hour)))
elif mins == 15:
	print('quarter past {}'.format(hour_to_str(hour)))
elif mins == 45:
	if hour == 12:
		print('quarter to {}'.format(hour_to_str(1)))
	else:
		print('quarter to {}'.format(hour_to_str(hour + 1)))
elif mins == 1:
	print('one minute past {}'.format(hour_to_str(hour)))
elif mins < 30:
	print('{} minutes past {}'.format(min_to_str(mins), hour_to_str(hour)))
elif mins == 59:
	if hour == 12:
		print('one minute to {}'.format(hour_to_str(1)))
	else:
		print('one minute to {}'.format(hour_to_str(hour + 1)))
elif hour == 12:
	print('{} minutes to {}'.format(min_to_str(60 - mins), hour_to_str(1)))
else:
	print('{} minutes to {}'.format(min_to_str(60 - mins), hour_to_str(hour + 1)))


def convert_time_to_string(hours, mintes):
	numbers_string = ['midnight', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seveteen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'half']
	if minutes == 0:
		result = numbers_string[hours] + " o' clock"
	elif minutes == 1:
		result = numbers_string[minutes] + ' minute past ' + numbers_string[hours]
	elif minutes > 0 and minutes < 30 and (minutes != 15):
		result = numbers_string[minutes] + ' minutes past ' + numbers_string[hours]
	elif minutes == 15:
		result = numbers_string[minutes] + ' past ' + numbers_string[hours]
	elif minutes == 30:
		result = numbers_string[minutes] + ' past ' + numbers_string[hours]
	elif minutes == 59:
		hours += 1
		if hours == 13:
			hours = 1
		result = numbers_string[60 - minutes] + ' minute to ' + numbers_string[hours]
	elif minutes == 45:
		hours += 1
		if hours == 13:
			hours = 1
		result = numbers_string[60 - minutes] + ' to ' + numbers_string[hours]
	else:
		hours += 1
		if hours == 13:
			hours = 1
		result = numbers_string[60 - minutes] + ' minutes to ' + numbers_string[hours]
	return result
hours = int(input())
minutes = int(input())
print(convert_time_to_string(hours, minutes))


def get_fuzzy(i):
	fuzzy_table = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 30: 'half', 0: "o' clock"}
	rstr = ''
	if i < 20:
		rstr = fuzzy_table[i]
	elif i < 30:
		rstr = fuzzy_table[20] + ' ' + fuzzy_table[i - 20]
	else:
		rstr = fuzzy_table[30]
	return rstr

def get_fuzzy_time(h, m):
	to_past = 'past'
	if m > 30:
		h += 1
		m = 60 - m
		to_past = 'to'
	h_str = get_fuzzy(h)
	m_str = get_fuzzy(m)
	if m == 1:
		m_str += ' minute'
	elif m != 15 and m != 30 and (m != 0):
		m_str += ' minutes'
	if m == 0:
		return h_str + ' ' + m_str
	else:
		return m_str + ' ' + to_past + ' ' + h_str
h = int(input().strip())
m = int(input().strip())
print(get_fuzzy_time(h, m))


l = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine']
hl = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one']
flag = 0
h = int(input())
if h == 12:
	flag = 1
s = input()
m = int(s)
if s[0] == '0' and s[1] == '0':
	print("%s o' clock" % l[h - 1])
elif s[0] == '0':
	if s[1] == '1':
		print('one minute past %s' % l[h - 1])
	else:
		x = int(s[1])
		print('%s minutes past %s' % (l[x - 1], l[h - 1]))
elif m > 9 and m < 30:
	if m == 15:
		print('quarter past %s' % l[h - 1])
	elif m > 9 and m < 15:
		print('%s minutes past %s' % (l[m - 1], l[h - 1]))
	else:
		print('%s minutes past %s' % (l[m - 2], l[h - 1]))
elif m == 30:
	print('half past %s' % l[h - 1])
elif m > 30 and m < 59:
	if m == 45:
		print('quarter to %s' % hl[h])
	elif m > 30 and m < 45:
		print('%s minutes to %s' % (l[60 - m - 2], hl[h]))
	else:
		print('%s minutes to %s' % (l[60 - m - 1], hl[h]))
elif m == 59:
	print('one minute to %s' % hl[h])


h = int(input())
m = int(input())

def words(n):
	if n < 20:
		return ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'][n - 1]
	value = ['twenty', 'thirty', 'fourty', 'fifty'][int(n / 10) - 2]
	if n % 10:
		value += ' ' + words(n % 10)
	return value

def pural(m):
	return 's' if m > 1 else ''
if m == 0:
	print(words(h) + " o' clock")
elif m == 15:
	print('quarter past ' + words(h))
elif m == 30:
	print('half past ' + words(h))
elif m == 45:
	print('quarter to ' + words(h + 1))
elif m < 30:
	print(words(m) + ' minute' + pural(m) + ' past ' + words(h))
else:
	print(words(60 - m) + ' minute' + pural(60 - m) + ' to ' + words(h + 1))


output = ''
hour = input()
minute = input()

def minutePlural(minute):
	if minute == 1:
		return 'minute '
	else:
		return 'minutes '

def numberToWord(n):
	n3 = []
	r1 = ''
	ns = str(n)
	for k in range(3, 33, 3):
		r = ns[-k:]
		q = len(ns) - k
		if q < -2:
			break
		elif q >= 0:
			n3.append(int(r[:3]))
		elif q >= -1:
			n3.append(int(r[:2]))
		elif q >= -2:
			n3.append(int(r[:1]))
		r1 = r
	nw = ''
	for (i, x) in enumerate(n3):
		b1 = x % 10
		b2 = x % 100 // 10
		b3 = x % 1000 // 100
		if x == 0:
			continue
		else:
			t = thousands[i]
		if b2 == 0:
			nw = ones[b1] + t + nw
		elif b2 == 1:
			nw = tens[b1] + t + nw
		elif b2 > 1:
			nw = twenties[b2] + ones[b1] + t + nw
		if b3 > 0:
			nw = ones[b3] + 'hundred ' + nw
	return nw
ones = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ']
tens = ['ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
twenties = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']
thousands = ['', 'thousand ', 'million ', 'billion ', 'trillion ', 'quadrillion ', 'quintillion ', 'sextillion ', 'septillion ', 'octillion ', 'nonillion ', 'decillion ', 'undecillion ', 'duodecillion ', 'tredecillion ', 'quattuordecillion ', 'quindecillion', 'sexdecillion ', 'septendecillion ', 'octodecillion ', 'novemdecillion ', 'vigintillion ']
hour = int(hour)
minute = int(minute)
if minute == 0:
	output = numberToWord(hour) + "o' clock"
elif minute > 0 and minute < 30 and (minute != 15):
	output = numberToWord(minute) + '' + minutePlural(minute) + 'past ' + numberToWord(hour)
elif minute == 15:
	output = 'quarter past ' + numberToWord(hour)
elif minute == 30:
	output = 'half past ' + numberToWord(hour)
elif minute > 30 and minute != 45:
	output = numberToWord(60 - minute) + 'minutes to ' + numberToWord(hour + 1)
else:
	output = 'quarter to ' + numberToWord(hour + 1)
print(output)


num1 = {0: '', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
tens = {2: 'twenty'}

def c2w(n):
	if 1 <= n <= 19:
		return num1[n]
	elif 20 <= n <= 59:
		(t, u) = divmod(n, 10)
		return tens[t] + ' ' + num1[u]
	else:
		return ''
h = int(input())
m = int(input())
if m == 0:
	print(c2w(h) + " o' clock")
elif m == 1:
	print('one minute past ' + c2w(h))
elif m == 15:
	print('quarter past ' + c2w(h))
elif 2 <= m <= 29:
	print(c2w(m) + ' minutes past ' + c2w(h))
elif m == 30:
	print('half past ' + c2w(h))
elif m == 45:
	print('quarter to ' + c2w(h + 1))
elif 31 <= m <= 59:
	print(c2w(60 - m) + ' minutes to ' + c2w(h + 1))


H = int(input())
M = int(input())
num = ['one', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'half']
num = num + num[-2:0:-1]
s = ''
if M == 0:
	print("{H} o' clock".format(H=num[H]))
else:
	if 0 < M <= 30 or 0 < 60 - M < 30:
		if M == 1 or 60 - M == 1:
			s += '{M} minute '
		elif M == 15 or 60 - M == 15 or M == 30:
			s += '{M} '
		else:
			s += '{M} minutes '
	if M <= 30:
		s += 'past '
	else:
		s += 'to '
	s += '{H}'
	if 0 < M <= 30:
		print(s.format(H=num[H], M=num[M]))
	else:
		print(s.format(H=num[(H + 1) % 13], M=num[M]))


numberwords = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'quarter', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'half']
(H, M) = (int(input()), int(input()))
if M == 0:
	print(numberwords[H], "o' clock")
elif M == 1:
	print(numberwords[1], 'minute past', numberwords[H])
elif M == 15 or M == 30:
	print(numberwords[M], 'past', numberwords[H])
elif M < 30:
	print(numberwords[M], 'minutes past', numberwords[H])
elif M == 45:
	print(numberwords[60 - M], 'to', numberwords[(H + 1) % 13])
elif M == 59:
	print(numberwords[1], 'minute to', numberwords[(H + 1) % 13])
else:
	print(numberwords[60 - M], 'minutes to', numberwords[(H + 1) % 13])


ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
tens = ['twenty', 'thirty', 'forty', 'fifty']
hour = int(input())
minute = int(input())
if hour == 12:
	hourAhead = 1
else:
	hourAhead = hour + 1
if minute == 0:
	print(ones[hour] + " o' clock")
elif minute == 15:
	print('quarter past ' + ones[hour])
elif minute == 30:
	print('half past ' + ones[hour])
elif minute == 45:
	print('quarter to ' + ones[hourAhead])
elif minute < 20:
	if minute < 20:
		print(ones[minute] + ' minutes past ' + ones[hour])
	else:
		print(ones[minute] + ' minutes past ' + ones[hour])
elif minute < 30:
	minuteTens = minute // 10
	minuteOnes = minute - minuteTens * 10
	print(tens[minuteTens - 2] + ' ' + ones[minuteOnes] + ' minutes past ' + ones[hour])
elif minute > 30:
	minute = 60 - minute
	minuteTens = minute // 10
	minuteOnes = minute - minuteTens * 10
	if minute < 20:
		print(ones[minute] + ' minutes to ' + ones[hourAhead])
	else:
		print(tens[minuteTens - 2] + ' ' + ones[minuteOnes] + ' minutes to ' + ones[hourAhead])