#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int MaxNum = 205;
int p[MaxNum];
int main()
{
//freopen("HDU1050.txt","r",stdin);
int n,m,s,t,tmp;
scanf("%d",&n);
while(n--)
{
memset(p,0,sizeof(p));
scanf("%d",&m);
while(m--)
{
scanf("%d%d",&s,&t);
s = (s - 1) >> 1;
t = (t - 1) >> 1;
if(s > t)
{
tmp = s;
s = t;
t = tmp;
}
for(int j = s;j <= t;j++)
p[j]++;
}
int max = -1;
for( int j = 0; j < MaxNum; j++)
if(p[j] > max)
max = p[j];
cout<<10*max<<endl;
}
return 0;
}