#include <stdio.h>
int main(void){
int hour, minute, makingtime, total;
scanf("%d %d", &hour, &minute);
scanf("%d", &makingtime);
total = minute + makingtime;
if(hour == 23 && minute + makingtime >= 60)
{
hour += total / 60;
total = total - 60 * (total / 60);
if(hour >= 24)
{
printf("%d %d", 0 + hour - 24, total);
}
else
{
printf("%d %d", hour, total);
}
}
else if(total >= 60)
{
hour += total / 60;
total = total - 60 * (total / 60);
if(hour >= 24)
{
printf("%d %d", 0 + hour - 24, total);
}
else
{
printf("%d %d", hour, total);
}
}
else
{
printf("%d %d", hour, total);
}
return 0;
}