Build a City
Time limit3sMemory limit1024 MB
Given settlements and a per-move wall budget m, decide whether some order of acquiring them keeps each move's new wall length within m.
Problem
Recently, you have become addicted to a game called "Build a City".
The game is played on a two-dimensional map. The map has human settlements labelled from to , where settlement is at for . Settlement is at the origin, so .
Your city is a rectangle made of walls, with sides parallel to the coordinate axes. A city contains a settlement when the settlement is inside or on the border of the rectangle.
At first, your city contains settlement and is a degenerate rectangle at the origin. In one move, you acquire an unoccupied settlement and build walls to enclose it. The new city is the smallest axis-parallel rectangle that contains everything the old city contained plus the new settlement. Your goal is to enclose all settlements in your city.
In one move, the infrastructure department can build walls of total length up to . Existing walls can be reused, but they cannot be placed elsewhere. So the length of walls built in a move is the perimeter of the new rectangle minus the length of the common part of the old and new rectangles. If the new settlement is already inside the city, the length is zero.
You now want to know if there is an order in which to acquire the settlements so that the total length of walls built in each move does not exceed .
Input
The first line of input contains one integer , the number of test cases (). For each test case:
The first line contains two integers and , the number of unoccupied settlements and the maximum total length of walls that can be built in one move (, ).
The -th of the following lines contains two integers and , the coordinates of settlement ().
The sum of over all test cases does not exceed .
Output
For each test case, output a line containing the word Yes if such an order exists, or the word No otherwise.