n = int(input())
tn = 480+30
du = 45
dp = 10
if(n==1):
tk=tn+du
else:
tk=tn+du+(n-1)*(du+dp)
h=tk // 60
m=tk % 60
print(h,':',m)
n = int(input())
tn = 480+30
du = 45
dp = 10
if(n==1):
tk=tn+du
else:
tk=tn+du+(n-1)*(du+dp)
h=tk // 60
m=tk % 60
print(h,':',m)