//需要重复操作的东西可以写成函数
//相差的时间就用秒数来解
//相同的东西可以用数组
//将读入统一进行处理,一般都是将一些东西统一后进行相同操作的处理,已经成型的算法就特判
//输入多组测试数据,过滤空行,得到所有秒数,得到时分秒,输出
//get_time:读入字符串,转化为相同格式,读入格式,返回
//get_second:得到秒
#include<iostream>
#include<cstring>
using namespace std;
const int N=10010;
int get_seconds(int h,int m,int s)//得到秒数,写函数
{
return h*3600+m*60+s;
}
int get_time()//得到飞行时间秒,写函数
{
string str;
getline(cin,str);//读入一行
if(str.back()!=')')str+=" (+0)";//将读入统一
int h1,m1,s1,h2,m2,s2,d;
sscanf(str.c_str(),"%d:%d:%d %d:%d:%d (+%d)",&h1,&m1,&s1,&h2,&m2,&s2,&d);//在已经储存的字符中读入
//sscanf这里str是string不能直接读入,必须通过c_str()转化为字符串形式读入
return get_seconds(h2,m2,s2)-get_seconds(h1,m1,s1)+d*24*3600;//返回相差时间,统一后加上天数的秒数
}
int main()
{
int T;cin>>T;
string a;
getline(cin,a);//过滤第一行整形的空行
while(T--)
{
int time=(get_time()+get_time())/2;//有时差,一去一回抵消,所以相加除以2就是真实飞行时间
int hour=time/3600,minute=time%3600/60,second=time%60;//得到时,分,秒的方法
printf("%02d:%02d:%02d\n",hour,minute,second);//printf输出时间自动补零
}
return 0;
}