#T512. 【NOIP2001-S1】铺地毯

【NOIP2001-S1】铺地毯

Description

To prepare for a unique awards ceremony, the organizers laid out several rectangular carpets in a rectangular area of the venue (which can be considered as the first quadrant of the plane coordinate system). There are a total of n carpets, numbered from 1 to n. The carpets are laid out sequentially in order of their numbers, parallel to the coordinate axes, with each new carpet covering those already laid.

After the carpets are laid, the organizers want to know the number of the topmost carpet covering a specific point on the ground. Note: Points on the edges or at the four corners of the rectangular carpets are also considered covered.

0083.png

Input Format

The input consists of n+2 lines.

The first line contains an integer n, representing the total number of carpets.

The next n lines describe the information for each carpet. The (i+1)-th line contains four positive integers a, b, g, and k, separated by spaces, representing the coordinates (a, b) of the bottom-left corner of the i-th carpet and its lengths along the x-axis and y-axis, respectively.

The (n+2)-th line contains two positive integers x and y, representing the coordinates (x, y) of the point to be queried.

Output Format

The output consists of 1 line, containing an integer representing the number of the topmost carpet covering the queried point. If no carpet covers the point, output -1.

```input1 3 1 0 2 3 0 2 3 3 2 1 3 3 2 2 ``` ```output1 3 ``` ```input2 3 1 0 2 3 0 2 3 3 2 1 3 3 4 5 ``` ```output2 -1 ``` ## Hint

【Sample Explanation 1】

As shown in the figure below, carpet 1 is represented by a solid line, carpet 2 by a dashed line, and carpet 3 by a double solid line. The topmost carpet covering point (2,2) is carpet 3.

0083.png


【Data Range】

30% n<=2

50% 0<=a,b,g,k<=100

100% 0<=n<=10000, 0<=a,b,g,k<=100000

Source

NOIP2011-S-Day1