#include<bits/stdc++.h>
using namespace std;
struct food{
char str[55];
int price;
}ff[1010],dd[1010],cc[1010];
bool cmp(food a,food b)
{
return a.price<b.price;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,c;
memset(ff,0,sizeof(ff));
memset(dd,0,sizeof(dd));
memset(cc,0,sizeof(cc));
scanf("%d%d%d",&a,&b,&c);
int sum=0;
getchar();
for(int i=0;i<a;i++)
{
scanf("%s",ff[i].str);
getchar();
scanf("%d",&ff[i].price);
}
sort(ff,ff+a,cmp);
sum+=ff[a/2].price;
for(int i=0;i<b;i++)
{
scanf("%s",dd[i].str);
getchar();
scanf("%d",&dd[i].price);
}
//printf("d=%d\n",b/2);
sort(dd,dd+b,cmp);
sum+=dd[b/2].price;
for(int i=0;i<c;i++)
{
scanf("%s",cc[i].str);
getchar();
scanf("%d",&cc[i].price);
}
sort(cc,cc+c,cmp);
sum+=cc[c/2].price;
printf("%d %s %s %s\n",sum,ff[a/2].str,dd[b/2].str,cc[c/2].str);
}
}
熟练掌握结构体的用法就好了