#include <stdio.h>int main(){ int w,a,s,d,f; scanf("%d %d %d",&w,&a,&s); d=w+(a+s)/60; f=(a+s)%60; if(d>=25) { printf("%d %d",d-25,f); } else { printf("%d %d",d,f); } return 0;}