https://www.acmicpc.net/problem/2884
h,m=map(int,input().split()) if m<45 : if h ==0 : h=23 m+=15 else : h-=1 m+=15 else : m-=45 print("%d %d"%(h,m))