杭电1050
#include<iostream>
#include<algorithm>
using namespace std;
int T,N,temp;
struct desk{
int From;
int To;
int jihao;
}data[505];
bool cmp(const desk &a,const desk &b)
{
if(a.From==b.From)
return a.To<b.To;
else
return a.From<b.From;
}
int main()
{
cin>>T;
while(T--)
{
cin>>N;
memset(data,0,sizeof(data));
for(int i=0;i<N;i++)
{ cin>>data[i].From>>data[i].To;
if(data[i].From>data[i].To)
{
temp=data[i].From;
data[i].From=data[i].To;
data[i].To=temp;
}
}
sort(data,data+N,cmp);
int count=0,tmp;
for(int k=0;k<N;k++)
{
if(data[k].jihao==0)
{
count++;
tmp=k;
data[k].jihao=1;
}
for(int j=k+1;j<N;j++)
if(data[j].jihao==0&&data[tmp].To<=data[j].From&&!(data[j].From%2==0&&(data[tmp].To==data[j].From-1)))
{ data[j].jihao=1;
tmp=j;
}
}
cout<<count*10<<endl;
}
return 0;
}