num = int(input())
h, m = 8 + (30 + 55 * num - 10) // 60, (30 + 55 * num - 10) % 60
if len(str(m)) == 1:
m = '0' + str(m)
print(h, m, sep=':')
num = int(input())
h, m = 8 + (30 + 55 * num - 10) // 60, (30 + 55 * num - 10) % 60
if len(str(m)) == 1:
m = '0' + str(m)
print(h, m, sep=':')