def printTime(s):
    h=s//3600
    m=(s%3600)//60 
    sec=s-((h*3600)+(m*60)) 
    if(h>12):
        h=h%12 
    if(h==0):
        h=12
    print(str(h).zfill(2)+":"+str(m).zfill(2)+":"+str(sec).zfill(2))
h,m,s=map(int,input().split(":"))
k,x=map(int,input().split())
time=(h*60*60)+(m*60)+s 
printTime(time+x)
printTime(time+(x//k))