/*#include<stdio.h>
int s[50001]= {};
int top;
void init()
{
top=-1;
}
void push(int data)
{
if(top==50000)
{
return ;
}
s[top]=data;
}
int pop()
{
int data;
if(top==-1)
{
return;
}
else
{
int p=s[top];
s[top]=0;
top--;
return p;
}
}
int main()
{
int i;
int k,sum=0;
char str[50005];
init();
gets(str);
for(i = 0; i<strlen(str); i++)
{
if(str[i]=='(')
{
push(5);
}
else
{
if(top==-1)
{
printf("bad");
return 0;
}
pop();
}
}
if(top==-1)
{
printf("good");
}
else
{
printf("bad");
}
return 0;
}
*/
/*
#include<stdio.h>
char s[300]= {};
int top;
void init()
{
top=-1;
}
void push(char data)
{
if(top==300)
{
return ;
}
top++;
s[top]=data;
}
char pop()
{
char data;
if(top==-1)
{
return;
}
data=s[top];
s[top]=0;
top--;
return data;
}
int main()
{
int i,n,k;
char str[205];
init();
scanf("%d", &n);
getchar();
gets(str);
for(i = n-1; i>=0 ; i--)
{
push(str[i]);
if((n-i)%3==0)
{
if(n%3==0 && i==0) break;
push(',');
}
}
k = top;
for(i = 0; i<=k; i++)
{
printf("%c",pop());
}
return 0;
}
#include<stdio.h>
int s[201]= {};
int top;
void init()
{
top=-1;
}
void push(int data)
{
if(top==200)
{
return ;
}
top++;
s[top]=data;
}
int pop()
{
int data;
if(top==-1)
{
return;
}
data = s[top];
s[top]=0;
top--;
return data;
}
int main()
{
int i,a,b,c=0;
int k,sum=0;
char str[201];
init();
gets(str);
for(i = 0; i<strlen(str); i++)
{
if(48<=str[i]&&str[i]<=57)
{
c = c*10 + str[i]-'0';
if(str[i+1]==' ')
{
push(c);
c = 0;
}
}
else if(str[i]=='+')
{
b=pop();
a=pop();
push(a+b);
}
else if(str[i]=='-')
{
b = pop();
a = pop();
push(a-b);
}
else if(str[i]=='*')
{
b=pop();
a=pop();
push(a*b);
}
}
printf("%d",pop());
return 0;
}
*/
#include<stdio.h>
int main()
{
int a,b,c,i,j,n;
scanf("%d %d %d", &a,&b,&c);
if(b+c>=60)
{
a=(a+(b+c)/60)%24;
b=(b+c)%60;
}
else
{
b=b+c;
}
printf("%d %d", a,b);
return 0;
}