spoj#QUEST5. Nail Them

Nail Them

To get to the treasure, Jones must complete one more task. He comes across a table, where there are a number of wooden planks lying along the length of the table. He notices that the width of the table is exactly equal to the width of every plank on it. The planks are so heavy that they cannot be manually moved in any way. Some of these wooden planks are overlapping. Jones has a hammer and the Gods grant him infinite nails. The planks have to be joined to the table with nails such that every plank is connected to the table through at least one nail. The nails are of sufficient length, and have to be hammered vertically into the table. One or more planks can be joined to the table through a single nail provided they have a common overlap. Find out the minimum number of nails he needs to nail all planks to the table.

Planks

Input

  • The first line of the input is a positive integer t <= 20, denoting the number of tables.
  • The descriptions of the table follow one after the other.
    </li><li> <b>Table description:</b>
    <ul>
    
    	<li> The first line of the description of the <b>k<sup>th</sup></b> table contains a positive integer <b>n (n &lt;= 10010)</b>, the number of planks on it. 
    	</li><li> This is followed by <b>n</b> lines containing the description of the planks.
    	</li><li> The description of each plank is a pair of integers <b>a</b> and <b>b</b> <b>(0 &lt;= a &lt;= b &lt;= 10000010)</b>, denoting the distance of the left end and right end of the plank from the left end of the table.
    </li></ul>
    

Output

The output must contain t lines , the kth line corresponding to the kth table. The output on the kth line must be an integer ik, the minimum number of nails required.

Example

Input:
2
3
1 5
3 5
2 4
2
1 4
4 5

Output:
1
1