#include<stdio.h>
#include<iostream>
using namespace std;
int n;
int arr[410];
void f(int x,int y)
{
for(int i=x;i<=y;i++) arr[i]++;
}
int main()
{
freopen("in1.txt","r",stdin);
int i;
cin>>n;
while(n)
{
n--;
memset(arr,0,sizeof(arr));
int count;
cin>>count;
for(i=0;i<count;i++)
{
int n1;
int n2;
cin>>n1>>n2;
if(n1>n2)
{
int temp=n1;
n1=n2;
n2=temp;
}
n1=(n1+1)/2;
n2=(n2+1)/2;
f(n1,n2);
}
int max=0;
for(i=1;i<=400;i++)
{
if(max<arr[i]) max=arr[i];
}
cout<<max*10<<endl;
}
return 0;
}