#include <iostream>
#include <string>
#include<math.h>
using namespace std;
int main()
{
int n;
int AH, AM, AS, BH, BM, BS;
int sh, sm, ss;
while (cin >> n)
{
while (n--)
{
cin >> AH >> AM >> AS >> BH >> BM >> BS;
sh = 0; sm = 0; ss = 0;
ss = AS + BS;
if (ss > 59)
{
++sm; ss -= 60;
}
sm += AM + BM;
if (sm > 59)
{
++sh;
sm -= 60;
}
sh += AH + BH;
cout << sh << " " << sm << " " << ss << endl;
}
}
return 0;
}
#include <string>
#include<math.h>
using namespace std;
int main()
{
int n;
int AH, AM, AS, BH, BM, BS;
int sh, sm, ss;
while (cin >> n)
{
while (n--)
{
cin >> AH >> AM >> AS >> BH >> BM >> BS;
sh = 0; sm = 0; ss = 0;
ss = AS + BS;
if (ss > 59)
{
++sm; ss -= 60;
}
sm += AM + BM;
if (sm > 59)
{
++sh;
sm -= 60;
}
sh += AH + BH;
cout << sh << " " << sm << " " << ss << endl;
}
}
return 0;
}