cho.sh
Notes
Loading...

Rectangles and Shape

Time limit

2s

Memory limit

128 MB

Problem

On a two-dimensional plane, a shape is defined by n points, and m axis-aligned rectangles are given. The points of the shape are connected in the given order, and the last point is connected back to the first point.

No two different rectangles share any region with positive area. You may choose some of the given rectangles to cover the shape. A chosen rectangle must not extend outside the shape, and every part of the shape's interior must be covered by a chosen rectangle.

Input

The first line contains two natural numbers n and m (1 <= n <= 1,000, 1 <= m <= 10,000).

Each of the next n lines contains the coordinates of one point of the shape, in order.

Each of the next m lines contains four integers: the x- and y-coordinates of two opposite corners of one rectangle.

Output

Print the number C of selected rectangles on the first line. Then print the numbers of the selected rectangles, one per line, in increasing order.

If the shape cannot be covered, print C = 0.