#include<iostream>
#define MAXN 1005
using namespace std; int a[MAXN]; int main()
{
//freopen("acm.acm","r",stdin);
int test;
int num;
char c;
int i;
int j;
int x;
int max;
int y;
cin>>test;
while(test --)
{
memset(a,,sizeof(a));
cin>>num;
max = -;
for(i = ; i < num; ++ i)
{
cin>>c;
cin>>x>>y;
if(x > max)
max = x;
if(y > max)
max = y;
for(j = x; j < y; ++ j)
{
++ a[j];
}
}
for(i = ; i < max; ++ i)
{
if(a[i] == )
continue;
else
cout<<char(a[i]-+);
}
cout<<endl;
}
}