#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n, ah, am, as, bh, bm, bs;
int result_s, result_m, result_h;
while(cin >> n)
{
while(n --)
{
cin >> ah >> am >> as >> bh >> bm >> bs;
result_s = (as + bs) % 60;
result_m = (am + bm) % 60 + (as + bs) / 60;
result_h = ah + bh + (am + bm) / 60;
cout << result_h << " " << result_m << " " << result_s << endl;
}
}
return 0;
}