#include <stdio.h>
#include <stdlib.h>
struct time
{
int m;
int h;
}time[105];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int i;
char c;
time[0].h=13;
time[0].m=15;
for(i=1;i<=n;i++)
{
scanf("%d%c%d",&time[i].h,&c,&time[i].m);
}
for(i=1;i<=n;i++)
{
if(time[i].m+time[0].m<60 && time[i].h+time[0].h<24)
{
time[i].m=time[i].m+time[0].m;
time[i].h+=time[0].h;
}
else if(time[i].m+time[0].m>60 && time[i].h+time[0].h>24)
{
time[i].m=time[i].m+time[0].m-60;
time[i].h+=time[0].h+1-24;
}
else if(time[i].m+time[0].m<60 && time[i].h+time[0].h>24)
{
time[i].m=time[i].m+time[0].m;
time[i].h+=time[0].h-24;
}
else if(time[i].m+time[0].m>60 && time[i].h+time[0].h<24)
{
time[i].m=time[i].m+time[0].m-60;
time[i].h+=time[0].h;
}
printf("%d:%d\n",time[i].h,time[i].m);
}
}
return 0;
}