#include<stdio.h>
int main()
{
int ah,am,as,bh,bm,bs,i,k,n,zh,zm,zs;
while( scanf("%d",&n) != EOF )
{
for ( k=0; k<n; k++ )
{
ah=0, am=0, as=0, bm=0, bh=0, bs=0, zm=0, zh=0, zs=0;
scanf("%d %d %d %d %d %d",&ah,&am,&as,&bh,&bm,&bs);
zs=as+bs;
zm=am+bm;
zh=ah+bh;
if(zs>59)
{
zs=zs-60;
zm=zm+1;
}
if(zm>59)
{
zm=zm-60;
zh=zh+1;
}
printf("%d %d %d\n",zh,zm,zs);
}
}
return 0;
}