#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
cin>>n;
cin.get();
int h,m,s,k;
int h1,m1,s1,h2,m2,s2;
int t1,t2,t;
while(n--)
{
cin>>h>>m>>s>>k;
t=h*3600+m*60+s;
t1=t-k;
t2=t+k;
if(t1<0)
t1+=3600*24;
h1=t1/3600;
if(t2>=(3600*24))
t2-=3600*24;
h2=t2/3600;
m1=(t1%3600)/60;
m2=(t2%3600)/60;
s1=(t1%3600)%60;
s2=(t2%3600)%60;
printf("%02d:%02d:%02d %02d:%02d:%02d\n",h1,m1,s1,h2,m2,s2);
}
return 0;
}
呜呜呜改了好久才改对