Hide

Problem D
For the Belt

It’s the year 2350 and tensions between Earth and Mars are at an all time high. As the two factions attempt to settle their differences through peace talks, Fred Johnson and the belt are secretly assembling a large fleet in the outer reaches of the solar system. Due to the lack of necessity for aerodynamic signatures in deep space ships, we are standardizing the process and building the ships in a rectangular shape. These ships are parked on a large rectangular area as well. However, this parking area is frequently littered with objects and can only house one ship at a time. Find the largest surface area we can have for a ship within the confines of the rectangular parking area that does not overlap anything on the floor. The sides of the ship must be parallel to the sides of the parking area for easy mobilization.

Input

The first line will specify the number of cases you may have. The second line will have the length and width of the parking space in meters. Both of these numbers will be less than or equal to 10000. The following lines will describe either a single point of obstruction on the parking space or a line of obstructions, and they will be provided as follows:

  • A single object and x and y coordinates with respect to the upper left corner of the parking area.

  • Z x y where Z equals 1 and provides the coordinates of a single obstruction located at (x, y)

  • Z x y dx dy where Z is greater than 1 and provides the number of obstructions in the zone in a line with the coordinates (x, y), (x + dx, y + dy), ... , (x+(Z-1)dx, y+(Z-1)dy).

  • Each scenario of the parking area and obstructions will terminate with a 0.

There will not be any more than 1000 obstructions in the parking area.

Output

Output a line with the maximum size that the ship can occupy in the parking space in square meters.

Sample Input 1 Sample Output 1
3
4 5
1 2 3
0
25 25
2 1 9 4 0
2 1 2 7 0
0
10 10
0
12
460
100

Please log in to submit a solution to this problem

Log in