/*
#include<stdio.h>
int main()
{
int i;
for(i=1 ; i<101 ; i=i+1)
{
printf("%d ",i);
}
return 0;
}
*/
/*
#include<stdio.h>
int main()
{
int a,b;
scanf("%d",&a);
for(b=1 ; b<=a ; b=b+1)
{
printf("%d ",b);
}
return 0;
}
*/
/*
#include<stdio.h>
int main()
{
int a,b,c,d,e;
scanf("%d-%d",&a,&b);
c=a/10000;
d=(a%10000-a%100)/100;
e=a%100;
if(b/1000000==1)
{
printf("19%02d/%02d/%02d M",c,d,e);
}
else if(b/1000000==2)
{
printf("19%02d/%02d/%02d F",c,d,e);
}
else if(b/1000000==3)
{
printf("20%02d/%02d/%02d M",c,d,e);
}
else if(b/1000000==4)
{
printf("20%02d/%02d/%02d F",c,d,e);
}
return 0;
}
*/
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d %d\n%d",&a,&b,&c);
if(b+c<60)
{
printf("%d %d",a,b+c);
}
else if(b+c>=60)
{
printf("%d %d",a+1,b+c-60);
}
return 0;
}