Hide

# Problem FFiring the Phaser

Illustration of a solution to Sample Input 1
As captain of your space ship you have never encountered a more fierce enemy than the one you have snuck upon now. You immediately bring out the big phaser cannon hoping to take out the flagship before they discover you. There is no room for mistakes and the shot will have to be perfect if you are to stand any chance at all against the flagship of the enemy.

You start charging the phaser beam and retrieve the room layout of the flagship from the archives. You are situated directly above the enemy, from where the layout of the flagship can be modeled by a two-dimensional map of the rooms of the flagship. In this map, each room is a rectangle with sides parallel to the $x$ and $y$ axes (rectilinear), and no two rooms intersect (not even in a single point).

The phaser beam is configured by giving a point $(x, y)$ and an angle $\vartheta$. The phaser beam will start at $(x, y)$ and travel a distance $\ell$ in the direction specified by $\vartheta$, causing severe damage to every room touched by the phaser beam. Due to this, you aim at hitting as many rooms as possible.

The phaser beam is almost fully charged and the only missing piece is an optimal configuration of the weapon. Unfortunately, it turns out to be harder than you expected. However, there are still ten seconds before the charging is completed and hence you decide to make a computer program to solve the problem.

## Input

The first line of input consists of two integers $r$ and $\ell$ ($1 \le r \le 15$, $1 \le \ell \le 1\, 000$) where $r$ is the number of rooms in the flagship and $\ell$ is the length of a shot of the phaser.

Then follow $r$ lines, each of which contains four integers $x_1$, $y_1$, $x_2$, $y_2$ ($0 \le x_1 < x_2 \le 1\, 000$, $0 \le y_1 < y_2 \le 1\, 000$), indicating that there is a room in the flagship with lower left corner $(x_1, y_1)$ and upper right corner $(x_2, y_2)$.

## Output

Output one line with the maximum number of rooms that can be hit by one phaser beam. Recall that if the beam touches a room it is counted as a hit.

You may assume that the answer is numerically stable in the following sense: if all rooms are expanded by a distance of $10^{-6}$ in all four directions, the answer does not change.

Sample Input 1 Sample Output 1
5 8
2 1 4 5
5 1 12 4
5 5 9 10
1 6 4 10
2 11 7 14

4

Sample Input 2 Sample Output 2
3 6
2 2 3 3
5 3 6 4
6 6 7 7

3

CPU Time limit 3 seconds
Memory limit 1024 MB
Statistics Show