# include int main() { int h, m, d, t; scanf("%d %d",&h, &m); scanf("%d",&d); t = 60*h+m+d; printf("%d %d",t/60%24,t%60); return 0; }