#include <stdio.h>
#include <string>
#include <iostream>
#include <set>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int num[2010];
int two[2010];
int dp[2010];
int main()
{
//freopen("read.txt", "r", stdin);
int T;
cin >> T;
while(T--)
{
memset(num, 0 , sizeof(num));
memset(dp, 0 , sizeof(dp));
memset(two, false , sizeof(two));
int n;
scanf("%d", &n);
for(int i=1; i<=n; i++)
scanf("%d", &num[i]);
for(int i=1; i<=n-1; i++)
{
scanf("%d", &two[i]);
}
dp[1] = num[1];
for(int i=2; i<=n; i++)
{
dp[i] = min(dp[i-1]+ num[i], dp[i-2] + two[i-1]);
}
int s=dp[n] %60;
int m=dp[n]/60%60;
int h =8 + dp[n-1] /3600;
char c1, c2;
if(h<12 || (h==12 && s==m && s==0) )
{
c1='a';
c2='m';
}
else
{
if(h!=12)
h%=12;
c1='p';
c2='m';
}
printf("%02d:%02d:%02d %c%c\n",h,m,s,c1,c2);
}
return 0;
}
附件列表