#include<iostream>
#include<math.h>
using namespace std;
typedef struct
{
int x;
int y;
}poi;
poi k[300];
int e=0;
void searc(poi *a,poi *b)
{
int q=0,w=0;
while(a[q].y>0)
{
for(w=0;b[w].y>0;w++)
{
if(a[q].y==b[w].y)
{
k[e].x=a[q].x+b[w].x;
k[e].y=a[q].x;
e++;
}
}
k[e].y=-1;
}
}
void swap(poi *x,poi *y)
{
poi temp=*y;
*x=*y;
*y=temp;
}
void fast(poi *a)
{
int pointed=0,pointet=1;
for(;a[pointed].y!=-1;pointed++)
{
for(pointet=pointed+1;a[pointet].y!=-1;pointet++)
{
if(a[pointed].y<a[pointet].y)
swap(&a[pointed],&a[pointet]);
}
}
}
main()
{
int n,h;
cin>>n;
poi i[300]=;
poi j[300]=;
while(n>0)
{
for(h=0;i[h].y>=0;h++)
{
cin>>i[h].x>>i[h].y;
}
for(h=0;j[h].y>=0;h++)
{
cin>>j[h].x>>j[h].y;
}
searc(i,j);
fast(k);
for(int p=0;k[p].y!=-1;p++)
cout<<"[ "<<k[p].x<<" "<<k[p].y<<" ] ";
cout<<endl;
n--;
}
return 0;
}