There are two towers having M floors parallel to each other.To increase mobility between the towers N bridges are propsed to be build.A bridge will begin at 1st tower(any floor) and end at 2nd tower(any floor).Since bridges may intersect,authorities have come to you to tell them the maximum amount of bridges that can be build such that no two towers intersect.Bridges starting from same floor or ending on same floor is not considered as intersecting.
The first line of input will contain the number of test cases T.Each test case will begin with one integer N indicating number of proposed bridges.Next line N lines will contain a pair of integers denoting the floor number of each tower for the propsed bridge.
For each test case print the maximum number of non-intersecting bridges in separate line.
0 < T <= 15
0 < N <=1000
0 < M <= 10^9
Problem Setter : Akshay Kumar
Problem Tester : Akshit Poddar