This page is still under construction.

Parts of this page are still being built. What you see may change.

Garden Informatization

Time limit2sMemory limit512 MB

Summary
Given a rectangle with up to 10 axis-aligned obstacle rectangles, place one or two non-overlapping axis-aligned beds to maximize total area.
Level

Hard8 of 10

Topics
Geometry, Brute force, Implementation, Math
Solved
No attempts yet

Problem

Stepan Petrovich's garden plot is a rectangle of size a×ba \times b. The plot contains nn buildings, and the base of each building is a rectangle with sides parallel to the sides of the plot.

Inspired by his neighbors' success, Stepan Petrovich wants to plant mm types of fruit crops on his plot (Stepan Petrovich's plot is in a northern region, so m=1m = 1 or m=2m = 2). For each crop type, Stepan Petrovich wants to allocate a separate rectangular bed with sides parallel to the sides of the plot. Naturally, the beds cannot occupy the territory occupied by buildings or other beds.

Stepan Petrovich wants to place the beds so that their total area is maximized. The beds must not intersect, but they may touch each other.

Given the dimensions of the plot and the coordinates of the buildings, determine the optimal placement of the beds.

Input

The first line of the input file contains two integers nn and mm (0≤n≤100 \le n \le 10; 1≤m≤21 \le m \le 2).

The second line contains two integers aa and bb (1≤a,b≤100001 \le a, b \le 10000).

The next nn lines each contain four integers xi,1,yi,1,xi,2,yi,2x_{i,1}, y_{i,1}, x_{i,2}, y_{i,2}, the coordinates of two opposite corners of a building (0≤xi,1<xi,2≤a0 \le x_{i,1} < x_{i,2} \le a, 0≤yi,1<yi,2≤b0 \le y_{i,1} < y_{i,2} \le b). Different buildings cannot intersect, but they may touch each other.

Output

Output mm lines to the output file, each containing the coordinates of two opposite corners of a proposed bed. The coordinates must be integers (a placement maximizing the total area of the beds can always be achieved with rectangles of integer coordinates).

If in your solution Stepan Petrovich should plant fewer than mm beds, output the line "0 0 0 0" for the beds that should not be planted (see example 2).

Examples2

  1. Example 1

    Input
    2 2
    7 5
    4 2 6 4
    0 1 2 2
    
    Expected output
    0 2 4 5
    2 0 7 2
    
  2. Example 2

    Input
    3 2
    4 4
    0 0 4 1
    0 1 1 4
    3 1 4 4
    
    Expected output
    1 1 3 4
    0 0 0 0