http://acm.hdu.edu.cn/showproblem.php?pid=1050
#include<iostream>
#include
<algorithm>
using namespace std;
struct Node
{
    
int st;//总是保存小的
    int et;//总是保存大的
}
;
bool comp(Node a,Node b)
{
    
if(a.st == b.st)
        
return a.et<b.et;
    
else
        
return a.st<b.st;
}

Node infor[
201];
int main()
{
    
int cas,n;
    cin
>>cas;
    
while(cas--)
    
{
        cin
>>n;
        
int i,j,k,a,b;
        
int hash[201];
        
for(i=0;i<n;i++)
        
{
            cin
>>a>>b;
            infor[i].st
=a<b?a:b;
            infor[i].et
=a>b?a:b;
        }

        sort(infor,infor
+n,comp);
        k
=0;
        hash[k
++]=infor[0].et;
        
for(i=1;i<n;i++)
        
{
            
for(j=0;j<k;j++)
            
{
                
if(hash[j]<infor[i].st)
                
{
                    
if(hash[j]%2==1 )//奇数时要考虑清楚
                    {
                        
/*
                         3 5 7
                         4 6 8
                         4->5 、6->7需要20分钟
                        
*/

                        
if( infor[i].st - hash[j] > 1)
                        
{
                            hash[j] 
= infor[i].et;
                            
break;
                        }

                    }

                    
else
                    
{
                        hash[j] 
= infor[i].et;
                        
break;
                    }

                }

            }

            
if(j==k)
                hash[k
++= infor[i].et;
        }

        cout
<<k*10<<endl;
    }

    
return 0;
}