T-island Intervals
Time Limit: 2 Seconds Memory Limit: 32768 KB
There are n intervals in the T-island. Two intervals are called "adjacent", if their common segment is strictly greater than k. We want to put some cannibals on the intervals, so that none of them eat each other. A cannibal can move from one interval to any of its adjacent intervals. Find the maximum number of cannibals we can put on the intervals of T-island.
Input
The first line of the input file contains a single integer t (1 ≤ t ≤ 100), the number of test cases. First line of each test case contains two integers 1≤n≤100000 and 1≤k≤1000000000, followed by n lines each containing two integers li and ri (-1000000000≤li≤ri≤1000000000), the left and right endpoints of the i-th interval.
Output
For each test case, output the maximum number of cannibals that can be put on the T-island.
Sample Input
2 3 1 1 3 2 6 4 8 3 2 1 10 2 8 4 6
Sample Output
2 2Submit
Source: 12th Iran Nationwide Internet Contest I